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
39 lines (33 loc) · 954 Bytes
/
DelegateProcessor.php
File metadata and controls
39 lines (33 loc) · 954 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
35
36
37
38
39
<?php
namespace Enqueue\Client;
use Interop\Queue\PsrContext;
use Interop\Queue\PsrMessage;
use Interop\Queue\PsrProcessor;
class DelegateProcessor implements PsrProcessor
{
/**
* @var ProcessorRegistryInterface
*/
private $registry;
/**
* @param ProcessorRegistryInterface $registry
*/
public function __construct(ProcessorRegistryInterface $registry)
{
$this->registry = $registry;
}
/**
* {@inheritdoc}
*/
public function process(PsrMessage $message, PsrContext $context)
{
$processorName = $message->getProperty(Config::PARAMETER_PROCESSOR_NAME);
if (false == $processorName) {
throw new \LogicException(sprintf(
'Got message without required parameter: "%s"',
Config::PARAMETER_PROCESSOR_NAME
));
}
return $this->registry->get($processorName)->process($message, $context);
}
}