mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 03:23:19 +00:00
35 lines
1007 B
PHP
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()));
|
|
}
|
|
}
|
|
}
|