Repository navigation
Expand file tree
/
Copy pathBuildClientRoutingPass.php
More file actions
47 lines (39 loc) · 1.52 KB
/
Copy pathBuildClientRoutingPass.php
File metadata and controls
47 lines (39 loc) · 1.52 KB
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
40
41
42
43
44
45
46
47
<?php
namespace Enqueue\Bundle\DependencyInjection\Compiler;
use Enqueue\Client\Config;
use Enqueue\Client\RouterProcessor;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class BuildClientRoutingPass implements CompilerPassInterface
{
use ExtractProcessorTagSubscriptionsTrait;
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$processorTagName = 'enqueue.client.processor';
$routerId = RouterProcessor::class;
if (false == $container->hasDefinition($routerId)) {
return;
}
$events = [];
$commands = [];
foreach ($container->findTaggedServiceIds($processorTagName) as $serviceId => $tagAttributes) {
$subscriptions = $this->extractSubscriptions($container, $serviceId, $tagAttributes);
foreach ($subscriptions as $subscription) {
if (Config::COMMAND_TOPIC === $subscription['topicName']) {
$commands[$subscription['processorName']] = $subscription['queueName'];
} else {
$events[$subscription['topicName']][] = [
$subscription['processorName'],
$subscription['queueName'],
];
}
}
}
$router = $container->getDefinition($routerId);
$router->replaceArgument(1, $events);
$router->replaceArgument(2, $commands);
}
}