Conditions | 5 |
Paths | 5 |
Total Lines | 27 |
Lines | 27 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
26 | public function process(ContainerBuilder $container) |
||
27 | { |
||
28 | if (!$container->hasDefinition('ezpublish.search.common.field_registry')) { |
||
29 | return; |
||
30 | } |
||
31 | |||
32 | $fieldRegistryDefinition = $container->getDefinition('ezpublish.search.common.field_registry'); |
||
33 | |||
34 | foreach ($container->findTaggedServiceIds('ezpublish.fieldType.indexable') as $id => $attributes) { |
||
35 | foreach ($attributes as $attribute) { |
||
36 | if (!isset($attribute['alias'])) { |
||
37 | throw new LogicException( |
||
38 | 'ezpublish.fieldType.indexable service tag needs an "alias" attribute to ' . |
||
39 | 'identify the indexable field type. None given.' |
||
40 | ); |
||
41 | } |
||
42 | |||
43 | $fieldRegistryDefinition->addMethodCall( |
||
44 | 'registerType', |
||
45 | [ |
||
46 | $attribute['alias'], |
||
47 | new Reference($id), |
||
48 | ] |
||
49 | ); |
||
50 | } |
||
51 | } |
||
52 | } |
||
53 | } |
||
54 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.