|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace KGzocha\Bundle\SearcherBundle\DependencyInjection\CompilerPass; |
|
4
|
|
|
|
|
5
|
|
|
use KGzocha\Bundle\SearcherBundle\DependencyInjection\Configuration; |
|
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
7
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @author Krzysztof Gzocha <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
class ChainSearchCompilerPass extends AbstractChainsCompilerPass |
|
13
|
|
|
{ |
|
14
|
|
|
const CHAIN_SEARCHER = 'chain_searcher'; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @inheritDoc |
|
18
|
|
|
*/ |
|
19
|
2 |
|
protected function processParam( |
|
20
|
|
|
$contextId, |
|
21
|
|
|
array &$paramConfig, |
|
22
|
|
|
ContainerBuilder $container |
|
23
|
|
|
) { |
|
24
|
2 |
|
$definition = $this->buildDefinition( |
|
25
|
|
|
$container, |
|
26
|
|
|
$contextId, |
|
27
|
2 |
|
$this->buildChainServiceName( |
|
28
|
|
|
$contextId, |
|
29
|
2 |
|
self::SEARCHER_PARAMETER |
|
30
|
|
|
), |
|
31
|
2 |
|
$paramConfig[self::CHAIN_SEARCHER] |
|
32
|
|
|
); |
|
33
|
|
|
|
|
34
|
2 |
|
$this->addCellCollection($contextId, $paramConfig, $container, $definition); |
|
35
|
2 |
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @param string $contextId |
|
39
|
|
|
* @param array $paramConfig |
|
40
|
|
|
* @param ContainerBuilder $container |
|
41
|
|
|
* @param Definition $chainSearcher |
|
42
|
|
|
*/ |
|
43
|
2 |
|
private function addCellCollection( |
|
44
|
|
|
$contextId, |
|
45
|
|
|
array &$paramConfig, |
|
46
|
|
|
ContainerBuilder $container, |
|
47
|
|
|
Definition $chainSearcher |
|
48
|
|
|
) { |
|
49
|
2 |
|
if ($paramConfig[self::CHAIN_SEARCHER]['service']) { |
|
50
|
|
|
return; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
2 |
|
if (Configuration::CHAIN_SEARCHER_CLASS !== $paramConfig[self::CHAIN_SEARCHER]['class']) { |
|
54
|
1 |
|
return; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
1 |
|
$cellCollection = $container->getDefinition($this->buildChainServiceName( |
|
58
|
|
|
$contextId, |
|
59
|
1 |
|
CellCollectionCompilerPass::CELL_COLLECTION |
|
60
|
|
|
)); |
|
61
|
|
|
|
|
62
|
1 |
|
$chainSearcher->addArgument($cellCollection); |
|
63
|
1 |
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|