Code Duplication    Length = 20-37 lines in 12 locations

eZ/Publish/Core/Base/Container/Compiler/Search/SignalSlotPass.php 1 location

@@ 21-50 (lines=30) @@
18
 *
19
 * @deprecated Use {@see \eZ\Publish\Core\Base\Container\Compiler\Search\SearchEngineSignalSlotPass}
20
 */
21
class SignalSlotPass implements CompilerPassInterface
22
{
23
    public function process(ContainerBuilder $container)
24
    {
25
        if (!$container->hasDefinition('ezpublish.signalslot.signal_dispatcher')) {
26
            return;
27
        }
28
29
        $signalDispatcherDef = $container->getDefinition('ezpublish.signalslot.signal_dispatcher');
30
31
        foreach ($container->findTaggedServiceIds('ezpublish.search.slot') as $id => $attributes) {
32
            foreach ($attributes as $attribute) {
33
                if (!isset($attribute['signal'])) {
34
                    throw new LogicException(
35
                        "Could not find 'signal' attribute on '$id' service, " .
36
                        "which is mandatory for services tagged as 'ezpublish.persistence.solr.slot'"
37
                    );
38
                }
39
40
                $signalDispatcherDef->addMethodCall(
41
                    'attach',
42
                    array(
43
                        $attribute['signal'],
44
                        new Reference($id),
45
                    )
46
                );
47
            }
48
        }
49
    }
50
}
51

eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Compiler/FieldTypeParameterProviderRegistryPass.php 1 location

@@ 18-53 (lines=36) @@
15
/**
16
 * This compiler pass will register eZ Publish field type parameter providers.
17
 */
18
class FieldTypeParameterProviderRegistryPass implements CompilerPassInterface
19
{
20
    /**
21
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
22
     *
23
     * @throws \LogicException
24
     */
25
    public function process(ContainerBuilder $container)
26
    {
27
        if (!$container->hasDefinition('ezpublish.fieldType.parameterProviderRegistry')) {
28
            return;
29
        }
30
31
        $parameterProviderRegistryDef = $container->getDefinition('ezpublish.fieldType.parameterProviderRegistry');
32
33
        foreach ($container->findTaggedServiceIds('ezpublish.fieldType.parameterProvider') as $id => $attributes) {
34
            foreach ($attributes as $attribute) {
35
                if (!isset($attribute['alias'])) {
36
                    throw new \LogicException(
37
                        'ezpublish.fieldType.parameterProvider service tag needs an "alias" ' .
38
                        'attribute to identify the field type. None given.'
39
                    );
40
                }
41
42
                $parameterProviderRegistryDef->addMethodCall(
43
                    'setParameterProvider',
44
                    array(
45
                        // Only pass the service Id since field types will be lazy loaded via the service container
46
                        new Reference($id),
47
                        $attribute['alias'],
48
                    )
49
                );
50
            }
51
        }
52
    }
53
}
54

eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Compiler/RegisterStorageEnginePass.php 1 location

@@ 19-55 (lines=37) @@
16
/**
17
 * This compiler pass will register eZ Publish storage engines.
18
 */
19
class RegisterStorageEnginePass implements CompilerPassInterface
20
{
21
    /**
22
     * Performs compiler passes for persistence factories.
23
     *
24
     * Does:
25
     * - Registers all storage engines to ezpublish.api.storage_engine.factory
26
     *
27
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
28
     *
29
     * @throws \LogicException
30
     */
31
    public function process(ContainerBuilder $container)
32
    {
33
        if (!$container->hasDefinition('ezpublish.api.storage_engine.factory')) {
34
            return;
35
        }
36
37
        $storageEngineFactoryDef = $container->getDefinition('ezpublish.api.storage_engine.factory');
38
        foreach ($container->findTaggedServiceIds('ezpublish.storageEngine') as $id => $attributes) {
39
            foreach ($attributes as $attribute) {
40
                if (!isset($attribute['alias'])) {
41
                    throw new LogicException('ezpublish.storageEngine service tag needs an "alias" attribute to identify the storage engine. None given.');
42
                }
43
44
                // Register the storage engine on the main storage engine factory
45
                $storageEngineFactoryDef->addMethodCall(
46
                    'registerStorageEngine',
47
                    array(
48
                        new Reference($id),
49
                        $attribute['alias'],
50
                    )
51
                );
52
            }
53
        }
54
    }
55
}
56

eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Compiler/SignalSlotPass.php 1 location

@@ 19-38 (lines=20) @@
16
/**
17
 * This compiler pass will register slots in SignalDispatcher.
18
 */
19
class SignalSlotPass implements CompilerPassInterface
20
{
21
    public function process(ContainerBuilder $container)
22
    {
23
        if (!$container->hasDefinition('ezpublish.signalslot.signal_dispatcher')) {
24
            return;
25
        }
26
27
        $signalDispatcherDef = $container->getDefinition('ezpublish.signalslot.signal_dispatcher');
28
        foreach ($container->findTaggedServiceIds('ezpublish.api.slot') as $id => $attributes) {
29
            foreach ($attributes as $attribute) {
30
                if (!isset($attribute['signal'])) {
31
                    throw new LogicException("Could not find 'signal' attribute on '$id' service, which is mandatory for services tagged as 'ezpublish.api.slot'");
32
                }
33
34
                $signalDispatcherDef->addMethodCall('attach', array($attribute['signal'], new Reference($id)));
35
            }
36
        }
37
    }
38
}
39

eZ/Bundle/EzPublishRestBundle/DependencyInjection/Compiler/FieldTypeProcessorPass.php 1 location

@@ 15-38 (lines=24) @@
12
use Symfony\Component\DependencyInjection\ContainerBuilder;
13
use Symfony\Component\DependencyInjection\Reference;
14
15
class FieldTypeProcessorPass implements CompilerPassInterface
16
{
17
    public function process(ContainerBuilder $container)
18
    {
19
        if (!$container->hasDefinition('ezpublish_rest.field_type_processor_registry')) {
20
            return;
21
        }
22
23
        $definition = $container->getDefinition('ezpublish_rest.field_type_processor_registry');
24
25
        foreach ($container->findTaggedServiceIds('ezpublish_rest.field_type_processor') as $id => $attributes) {
26
            foreach ($attributes as $attribute) {
27
                if (!isset($attribute['alias'])) {
28
                    throw new \LogicException('ezpublish_rest.field_type_processor service tag needs an "alias" attribute to identify the field type. None given.');
29
                }
30
31
                $definition->addMethodCall(
32
                    'registerProcessor',
33
                    array($attribute['alias'], new Reference($id))
34
                );
35
            }
36
        }
37
    }
38
}
39

eZ/Bundle/EzPublishRestBundle/DependencyInjection/Compiler/InputHandlerPass.php 1 location

@@ 21-45 (lines=25) @@
18
 *
19
 * Tag attributes: format. Ex: json
20
 */
21
class InputHandlerPass implements CompilerPassInterface
22
{
23
    public function process(ContainerBuilder $container)
24
    {
25
        if (!$container->hasDefinition('ezpublish_rest.input.dispatcher')) {
26
            return;
27
        }
28
29
        $definition = $container->getDefinition('ezpublish_rest.input.dispatcher');
30
31
        // @todo rethink the relationships between registries. Rename if required.
32
        foreach ($container->findTaggedServiceIds('ezpublish_rest.input.handler') as $id => $attributes) {
33
            foreach ($attributes as $attribute) {
34
                if (!isset($attribute['format'])) {
35
                    throw new \LogicException('ezpublish_rest.input.handler service tag needs a "format" attribute to identify the input handler. None given.');
36
                }
37
38
                $definition->addMethodCall(
39
                    'addHandler',
40
                    array($attribute['format'], new Reference($id))
41
                );
42
            }
43
        }
44
    }
45
}
46

eZ/Bundle/EzPublishRestBundle/DependencyInjection/Compiler/InputParserPass.php 1 location

@@ 21-44 (lines=24) @@
18
 *
19
 * Tag attributes: mediaType. Ex: application/vnd.ez.api.Content
20
 */
21
class InputParserPass implements CompilerPassInterface
22
{
23
    public function process(ContainerBuilder $container)
24
    {
25
        if (!$container->hasDefinition('ezpublish_rest.input.parsing_dispatcher')) {
26
            return;
27
        }
28
29
        $definition = $container->getDefinition('ezpublish_rest.input.parsing_dispatcher');
30
31
        foreach ($container->findTaggedServiceIds('ezpublish_rest.input.parser') as $id => $attributes) {
32
            foreach ($attributes as $attribute) {
33
                if (!isset($attribute['mediaType'])) {
34
                    throw new \LogicException('ezpublish_rest.input.parser service tag needs a "mediaType" attribute to identify the input parser. None given.');
35
                }
36
37
                $definition->addMethodCall(
38
                    'addParser',
39
                    array($attribute['mediaType'], new Reference($id))
40
                );
41
            }
42
        }
43
    }
44
}
45

eZ/Bundle/EzPublishRestBundle/DependencyInjection/Compiler/ValueObjectVisitorPass.php 1 location

@@ 19-42 (lines=24) @@
16
 * Compiler pass for the ezpublish_rest.output.value_object_visitor tag.
17
 * Maps an fully qualified class to a value object visitor.
18
 */
19
class ValueObjectVisitorPass implements CompilerPassInterface
20
{
21
    public function process(ContainerBuilder $container)
22
    {
23
        if (!$container->hasDefinition('ezpublish_rest.output.value_object_visitor.dispatcher')) {
24
            return;
25
        }
26
27
        $definition = $container->getDefinition('ezpublish_rest.output.value_object_visitor.dispatcher');
28
29
        foreach ($container->findTaggedServiceIds('ezpublish_rest.output.value_object_visitor') as $id => $attributes) {
30
            foreach ($attributes as $attribute) {
31
                if (!isset($attribute['type'])) {
32
                    throw new \LogicException('ezpublish_rest.output.value_object_visitor service tag needs a "type" attribute to identify the field type. None given.');
33
                }
34
35
                $definition->addMethodCall(
36
                    'addVisitor',
37
                    array($attribute['type'], new Reference($id))
38
                );
39
            }
40
        }
41
    }
42
}
43

eZ/Publish/Core/Base/Container/Compiler/RegisterLimitationTypePass.php 1 location

@@ 18-51 (lines=34) @@
15
/**
16
 * This compiler pass will register eZ Publish field types.
17
 */
18
class RegisterLimitationTypePass implements CompilerPassInterface
19
{
20
    /**
21
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
22
     *
23
     * @throws \LogicException
24
     */
25
    public function process(ContainerBuilder $container)
26
    {
27
        if (!$container->hasDefinition('ezpublish.api.repository.factory')) {
28
            return;
29
        }
30
31
        $repositoryFactoryDef = $container->getDefinition('ezpublish.api.repository.factory');
32
33
        // Limitation types.
34
        // Alias attribute is the limitation type name.
35
        foreach ($container->findTaggedServiceIds('ezpublish.limitationType') as $id => $attributes) {
36
            foreach ($attributes as $attribute) {
37
                if (!isset($attribute['alias'])) {
38
                    throw new \LogicException('ezpublish.limitationType service tag needs an "alias" attribute to identify the limitation type. None given.');
39
                }
40
41
                $repositoryFactoryDef->addMethodCall(
42
                    'registerLimitationType',
43
                    array(
44
                        $attribute['alias'],
45
                        new Reference($id),
46
                    )
47
                );
48
            }
49
        }
50
    }
51
}
52

eZ/Publish/Core/Base/Container/Compiler/Search/FieldRegistryPass.php 1 location

@@ 19-53 (lines=35) @@
16
/**
17
 * This compiler pass will register eZ Publish indexable field types.
18
 */
19
class FieldRegistryPass implements CompilerPassInterface
20
{
21
    /**
22
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
23
     *
24
     * @throws \LogicException
25
     */
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
                    array(
46
                        $attribute['alias'],
47
                        new Reference($id),
48
                    )
49
                );
50
            }
51
        }
52
    }
53
}
54

eZ/Publish/Core/Base/Container/Compiler/Search/Legacy/CriterionFieldValueHandlerRegistryPass.php 1 location

@@ 19-50 (lines=32) @@
16
/**
17
 * This compiler pass will register Legacy Search Engine criterion field value handlers.
18
 */
19
class CriterionFieldValueHandlerRegistryPass implements CompilerPassInterface
20
{
21
    /**
22
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
23
     */
24
    public function process(ContainerBuilder $container)
25
    {
26
        if (!$container->hasDefinition('ezpublish.search.legacy.gateway.criterion_field_value_handler.registry')) {
27
            return;
28
        }
29
30
        $registry = $container->getDefinition('ezpublish.search.legacy.gateway.criterion_field_value_handler.registry');
31
32
        foreach ($container->findTaggedServiceIds('ezpublish.search.legacy.gateway.criterion_field_value_handler') as $id => $attributes) {
33
            foreach ($attributes as $attribute) {
34
                if (!isset($attribute['alias'])) {
35
                    throw new LogicException(
36
                        'ezpublish.search.legacy.gateway.criterion_field_value_handler service tag needs an "alias" attribute to identify the field type. None given.'
37
                    );
38
                }
39
40
                $registry->addMethodCall(
41
                    'register',
42
                    array(
43
                        $attribute['alias'],
44
                        new Reference($id),
45
                    )
46
                );
47
            }
48
        }
49
    }
50
}
51

eZ/Publish/Core/Base/Container/Compiler/Storage/Legacy/FieldValueConverterRegistryPass.php 1 location

@@ 19-48 (lines=30) @@
16
/**
17
 * This compiler pass will register Legacy Storage field value converters.
18
 */
19
class FieldValueConverterRegistryPass implements CompilerPassInterface
20
{
21
    /**
22
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
23
     */
24
    public function process(ContainerBuilder $container)
25
    {
26
        if (!$container->hasDefinition('ezpublish.persistence.legacy.field_value_converter.registry')) {
27
            return;
28
        }
29
30
        $registry = $container->getDefinition('ezpublish.persistence.legacy.field_value_converter.registry');
31
32
        foreach ($container->findTaggedServiceIds('ezpublish.storageEngine.legacy.converter') as $id => $attributes) {
33
            foreach ($attributes as $attribute) {
34
                if (!isset($attribute['alias'])) {
35
                    throw new LogicException('ezpublish.storageEngine.legacy.converter service tag needs an "alias" attribute to identify the field type. None given.');
36
                }
37
38
                $registry->addMethodCall(
39
                    'register',
40
                    array(
41
                        $attribute['alias'],
42
                        new Reference($id),
43
                    )
44
                );
45
            }
46
        }
47
    }
48
}
49