-
Notifications
You must be signed in to change notification settings - Fork 440
/
Copy pathBuildTopicMetaSubscribersPass.php
39 lines (30 loc) · 1.24 KB
/
BuildTopicMetaSubscribersPass.php
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\Bundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class BuildTopicMetaSubscribersPass implements CompilerPassInterface
{
use ExtractProcessorTagSubscriptionsTrait;
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$processorTagName = 'enqueue.client.processor';
if (false == $container->hasDefinition('enqueue.client.meta.topic_meta_registry')) {
return;
}
$topicsSubscribers = [];
foreach ($container->findTaggedServiceIds($processorTagName) as $serviceId => $tagAttributes) {
$subscriptions = $this->extractSubscriptions($container, $serviceId, $tagAttributes);
foreach ($subscriptions as $subscription) {
$topicsSubscribers[$subscription['topicName']][] = $subscription['processorName'];
}
}
$addTopicMetaPass = AddTopicMetaPass::create();
foreach ($topicsSubscribers as $topicName => $subscribers) {
$addTopicMetaPass->add($topicName, '', $subscribers);
}
$addTopicMetaPass->process($container);
}
}