|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace KGzocha\Bundle\SearcherBundle\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use KGzocha\Bundle\SearcherBundle\DependencyInjection\ServiceDefiner\Criteria; |
|
6
|
|
|
use KGzocha\Bundle\SearcherBundle\DependencyInjection\ServiceDefiner\CriteriaBuilder; |
|
7
|
|
|
use KGzocha\Bundle\SearcherBundle\DependencyInjection\ServiceDefiner\CriteriaBuilderCollection; |
|
8
|
|
|
use KGzocha\Bundle\SearcherBundle\DependencyInjection\ServiceDefiner\CriteriaCollection; |
|
9
|
|
|
use KGzocha\Bundle\SearcherBundle\DependencyInjection\ServiceDefiner\Searcher; |
|
10
|
|
|
use KGzocha\Bundle\SearcherBundle\DependencyInjection\ServiceDefiner\SearchingContext; |
|
11
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
12
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @author Krzysztof Gzocha <[email protected]> |
|
16
|
|
|
*/ |
|
17
|
|
|
class ContextsCompilerPass implements CompilerPassInterface |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @inheritDoc |
|
21
|
|
|
*/ |
|
22
|
1 |
|
public function process(ContainerBuilder $container) |
|
23
|
|
|
{ |
|
24
|
1 |
|
$contextParam = 'k_gzocha_searcher.contexts'; |
|
25
|
1 |
|
if (!$container->hasParameter($contextParam)) { |
|
26
|
|
|
throw new \InvalidArgumentException('Contexts are missing from the configuration.'); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
1 |
|
$contexts = $container->getParameter($contextParam); |
|
30
|
|
|
|
|
31
|
1 |
|
foreach ($contexts as $contextId => &$context) { |
|
32
|
1 |
|
CriteriaCollection::defineServices( |
|
33
|
|
|
$contextId, $context, $container |
|
34
|
|
|
); |
|
35
|
1 |
|
CriteriaBuilderCollection::defineServices( |
|
36
|
|
|
$contextId, $context, $container |
|
37
|
|
|
); |
|
38
|
1 |
|
Criteria::defineServices( |
|
39
|
|
|
$contextId, $context, $container |
|
40
|
|
|
); |
|
41
|
1 |
|
CriteriaBuilder::defineServices( |
|
42
|
|
|
$contextId, $context, $container |
|
43
|
|
|
); |
|
44
|
1 |
|
SearchingContext::defineServices( |
|
45
|
|
|
$contextId, $context, $container |
|
46
|
|
|
); |
|
47
|
1 |
|
Searcher::defineServices( |
|
48
|
|
|
$contextId, $context, $container |
|
49
|
|
|
); |
|
50
|
|
|
} |
|
51
|
1 |
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|