PHRAS-1251 Replace webhook job by queue worker

This commit is contained in:
Thibaud Fabre
2016-10-06 14:26:39 +02:00
parent c48b490e18
commit 15c533f709
9 changed files with 443 additions and 201 deletions

View File

@@ -9,13 +9,14 @@ use Alchemy\Phrasea\Webhook\Processor\CallableProcessorFactory;
use Alchemy\Phrasea\Webhook\Processor\FeedEntryProcessorFactory;
use Alchemy\Phrasea\Webhook\Processor\OrderNotificationProcessorFactory;
use Alchemy\Phrasea\Webhook\Processor\ProcessorFactory;
use Alchemy\Phrasea\Webhook\Processor\ProcessorInterface;
use Alchemy\Phrasea\Webhook\Processor\UserRegistrationProcessorFactory;
class EventProcessorFactory
{
/**
* @var ProcessorFactory
* @var ProcessorFactory[]
*/
private $processorFactories = [];
@@ -57,10 +58,20 @@ class EventProcessorFactory
/**
* @param WebhookEvent $event
* @return Processor\ProcessorInterface
* @deprecated Use getProcessor() instead
*/
public function get(WebhookEvent $event)
{
if (! isset($this->processorFactories[$event->getType()])) {
return $this->getProcessor($event);
}
/**
* @param WebhookEvent $event
* @return ProcessorInterface
*/
public function getProcessor(WebhookEvent $event)
{
if (!isset($this->processorFactories[$event->getType()])) {
throw new \RuntimeException(sprintf('No processor found for %s', $event->getType()));
}