forked from php-enqueue/enqueue-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDelegateProcessor.php
More file actions
34 lines (28 loc) · 866 Bytes
/
DelegateProcessor.php
File metadata and controls
34 lines (28 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
namespace Enqueue\Client;
use Enqueue\ProcessorRegistryInterface;
use Interop\Queue\Context;
use Interop\Queue\Message as InteropMessage;
use Interop\Queue\Processor;
class DelegateProcessor implements Processor
{
/**
* @var ProcessorRegistryInterface
*/
private $registry;
public function __construct(ProcessorRegistryInterface $registry)
{
$this->registry = $registry;
}
/**
* @return string|object
*/
public function process(InteropMessage $message, Context $context)
{
$processorName = $message->getProperty(Config::PROCESSOR);
if (false == $processorName) {
throw new \LogicException(sprintf('Got message without required parameter: "%s"', Config::PROCESSOR));
}
return $this->registry->get($processorName)->process($message, $context);
}
}