Files
Phraseanet/lib/Alchemy/Phrasea/Webhook/EventProcessorFactory.php
2015-10-26 14:25:59 +01:00

35 lines
1007 B
PHP

<?php
namespace Alchemy\Phrasea\Webhook;
use Alchemy\Phrasea\Model\Entities\WebhookEvent;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Webhook\Processor\FeedEntryProcessor;
use Alchemy\Phrasea\Webhook\Processor\UserRegistrationProcessor;
class EventProcessorFactory
{
private $app;
public function __construct(Application $app)
{
$this->app = $app;
}
public function get(WebhookEvent $event)
{
switch ($event->getType()) {
case WebhookEvent::FEED_ENTRY_TYPE:
return new FeedEntryProcessor(
$this->app,
$this->app['repo.feed-entries'],
$this->app['phraseanet.user-query']
);
case WebhookEvent::USER_REGISTRATION_TYPE:
return new UserRegistrationProcessor($this->app['repo.users']);
default:
throw new \RuntimeException(sprintf('No processor found for %s', $event->getType()));
}
}
}