|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
5
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
namespace eZ\Publish\Core\Base\Container\Compiler\Search\Legacy; |
|
8
|
|
|
|
|
9
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
10
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
11
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
12
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* This compiler pass will register Legacy Search Engine criterion handlers. |
|
16
|
|
|
*/ |
|
17
|
|
|
class CriteriaConverterPass implements CompilerPassInterface |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container |
|
21
|
|
|
*/ |
|
22
|
|
|
public function process(ContainerBuilder $container) |
|
23
|
|
|
{ |
|
24
|
|
|
if ( |
|
25
|
|
|
!$container->hasDefinition('ezpublish.search.legacy.gateway.criteria_converter.content') && |
|
26
|
|
|
!$container->hasDefinition('ezpublish.search.legacy.gateway.criteria_converter.location') && |
|
27
|
|
|
!$container->hasDefinition('ezpublish.spi.persistence.legacy.url.criterion_converter') |
|
28
|
|
|
) { |
|
29
|
|
|
return; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
if ($container->hasDefinition('ezpublish.search.legacy.gateway.criteria_converter.content')) { |
|
33
|
|
|
$criteriaConverterContent = $container->getDefinition('ezpublish.search.legacy.gateway.criteria_converter.content'); |
|
34
|
|
|
|
|
35
|
|
|
$contentHandlers = $container->findTaggedServiceIds('ezpublish.search.legacy.gateway.criterion_handler.content'); |
|
36
|
|
|
|
|
37
|
|
|
$this->addHandlers($criteriaConverterContent, $contentHandlers); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
if ($container->hasDefinition('ezpublish.search.legacy.gateway.criteria_converter.location')) { |
|
41
|
|
|
$criteriaConverterLocation = $container->getDefinition('ezpublish.search.legacy.gateway.criteria_converter.location'); |
|
42
|
|
|
|
|
43
|
|
|
$locationHandlers = $container->findTaggedServiceIds('ezpublish.search.legacy.gateway.criterion_handler.location'); |
|
44
|
|
|
|
|
45
|
|
|
$this->addHandlers($criteriaConverterLocation, $locationHandlers); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
if ($container->hasDefinition('ezpublish.spi.persistence.legacy.url.criterion_converter')) { |
|
49
|
|
|
$urlCriteriaConverter = $container->getDefinition('ezpublish.spi.persistence.legacy.url.criterion_converter'); |
|
50
|
|
|
$urlCriteriaHandlers = $container->findTaggedServiceIds('ezpublish.persistence.legacy.url.criterion_handler'); |
|
51
|
|
|
|
|
52
|
|
|
$this->addHandlers($urlCriteriaConverter, $urlCriteriaHandlers); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
protected function addHandlers(Definition $definition, $handlers) |
|
57
|
|
|
{ |
|
58
|
|
|
foreach ($handlers as $id => $attributes) { |
|
59
|
|
|
$definition->addMethodCall('addHandler', array(new Reference($id))); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|