|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* AnimeDb package. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Peter Gribanov <[email protected]> |
|
6
|
|
|
* @copyright Copyright (c) 2011, Peter Gribanov |
|
7
|
|
|
* @license http://opensource.org/licenses/GPL-3.0 GPL v3 |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace AnimeDb\Bundle\CatalogBundle\DependencyInjection\Compiler; |
|
11
|
|
|
|
|
12
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
13
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
14
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Plugin compiler pass. |
|
18
|
|
|
* |
|
19
|
|
|
* @author Peter Gribanov <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class PluginPass implements CompilerPassInterface |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @param ContainerBuilder $container |
|
25
|
|
|
*/ |
|
26
|
2 |
|
public function process(ContainerBuilder $container) |
|
27
|
|
|
{ |
|
28
|
2 |
|
$this->compilerChain($container, 'anime_db.plugin.filler', 'anime_db.filler'); |
|
29
|
2 |
|
$this->compilerChain($container, 'anime_db.plugin.search_fill', 'anime_db.search'); |
|
30
|
2 |
|
$this->compilerChain($container, 'anime_db.plugin.refiller', 'anime_db.refiller'); |
|
31
|
2 |
|
$this->compilerChain($container, 'anime_db.plugin.import', 'anime_db.import'); |
|
32
|
2 |
|
$this->compilerChain($container, 'anime_db.plugin.export', 'anime_db.export'); |
|
33
|
2 |
|
$this->compilerChain($container, 'anime_db.plugin.item', 'anime_db.item'); |
|
34
|
2 |
|
$this->compilerChain($container, 'anime_db.plugin.setting', 'anime_db.setting'); |
|
35
|
2 |
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param ContainerBuilder $container |
|
39
|
|
|
* @param string $chain_name |
|
40
|
|
|
* @param string $tag |
|
41
|
|
|
*/ |
|
42
|
2 |
|
private function compilerChain(ContainerBuilder $container, $chain_name, $tag) |
|
43
|
|
|
{ |
|
44
|
2 |
|
if (!$container->has($chain_name)) { |
|
45
|
1 |
|
return; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
1 |
|
$definition = $container->findDefinition($chain_name); |
|
49
|
1 |
|
$taggedServices = $container->findTaggedServiceIds($tag); |
|
50
|
1 |
|
foreach ($taggedServices as $id => $attributes) { |
|
51
|
1 |
|
$definition->addMethodCall('addPlugin', [new Reference($id)]); |
|
52
|
1 |
|
} |
|
53
|
1 |
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|