-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathFilterCompilerPass.php
More file actions
41 lines (34 loc) · 1.17 KB
/
FilterCompilerPass.php
File metadata and controls
41 lines (34 loc) · 1.17 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
<?php
/**
* @copyright 2014 Integ S.A.
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
* @author Javier Lorenzana <javier.lorenzana@gointegro.com>
*/
namespace GoIntegro\Bundle\HateoasBundle\DependencyInjection\Compiler;
// DI.
use Symfony\Component\DependencyInjection\ContainerBuilder,
Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface,
Symfony\Component\DependencyInjection\Reference;
class FilterCompilerPass implements CompilerPassInterface
{
const SERVICE_NAME = 'hateoas.repo_helper',
TAG_NAME = 'hateoas.repo_helper.filter',
METHOD_NAME = 'addFilter';
/**
* @param ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition(self::SERVICE_NAME)) {
return;
}
$definition = $container->getDefinition(self::SERVICE_NAME);
$taggedServices = $container->findTaggedServiceIds(self::TAG_NAME);
foreach (array_keys($taggedServices) as $id) {
$definition->addMethodCall(
self::METHOD_NAME, [new Reference($id)]
);
}
return $this;
}
}