-
Notifications
You must be signed in to change notification settings - Fork 440
/
Copy pathBuildExtensionsPass.php
36 lines (28 loc) · 1.13 KB
/
BuildExtensionsPass.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
<?php
namespace Enqueue\Bundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
class BuildExtensionsPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$tags = $container->findTaggedServiceIds('enqueue.consumption.extension');
$groupByPriority = [];
foreach ($tags as $serviceId => $tagAttributes) {
foreach ($tagAttributes as $tagAttribute) {
$priority = isset($tagAttribute['priority']) ? (int) $tagAttribute['priority'] : 0;
$groupByPriority[$priority][] = new Reference($serviceId);
}
}
ksort($groupByPriority);
$flatExtensions = [];
foreach ($groupByPriority as $extension) {
$flatExtensions = array_merge($flatExtensions, $extension);
}
$container->getDefinition('enqueue.consumption.extensions')->replaceArgument(0, $flatExtensions);
}
}