1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Sonata\DoctrinePHPCRAdminBundle\DependencyInjection\Compiler; |
15
|
|
|
|
16
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
18
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author Thomas Rabaix <[email protected]> |
22
|
|
|
* @author Nacho Martín <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
class AddGuesserCompilerPass implements CompilerPassInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* {@inheritdoc} |
28
|
|
|
* |
29
|
|
|
* Add tagged sonata guessers to their respective builders. |
30
|
|
|
*/ |
31
|
|
|
public function process(ContainerBuilder $container): void |
32
|
|
|
{ |
33
|
|
|
// ListBuilder |
34
|
|
|
$definition = $container->getDefinition('sonata.admin.guesser.doctrine_phpcr_list_chain'); |
35
|
|
|
$services = []; |
36
|
|
|
foreach ($container->findTaggedServiceIds('sonata.admin.guesser.doctrine_phpcr_list') as $id => $attributes) { |
37
|
|
|
$services[] = new Reference($id); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
$definition->replaceArgument(0, $services); |
41
|
|
|
|
42
|
|
|
// DatagridBuilder |
43
|
|
|
$definition = $container->getDefinition('sonata.admin.guesser.doctrine_phpcr_datagrid_chain'); |
44
|
|
|
$services = []; |
45
|
|
|
foreach ($container->findTaggedServiceIds('sonata.admin.guesser.doctrine_phpcr_datagrid') as $id => $attributes) { |
46
|
|
|
$services[] = new Reference($id); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$definition->replaceArgument(0, $services); |
50
|
|
|
|
51
|
|
|
// ShowBuilder |
52
|
|
|
$definition = $container->getDefinition('sonata.admin.guesser.doctrine_phpcr_show_chain'); |
53
|
|
|
$services = []; |
54
|
|
|
foreach ($container->findTaggedServiceIds('sonata.admin.guesser.doctrine_phpcr_show') as $id => $attributes) { |
55
|
|
|
$services[] = new Reference($id); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$definition->replaceArgument(0, $services); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|