Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

FieldTypeCollectionPass.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\Base\Container\Compiler;
8
9 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
10 use Symfony\Component\DependencyInjection\ContainerBuilder;
11 use LogicException;
12
16 class FieldTypeCollectionPass implements CompilerPassInterface
17 {
23 public function process(ContainerBuilder $container)
24 {
25 if (!$container->hasDefinition('ezpublish.field_type_collection.factory')) {
26 return;
27 }
28
29 $fieldTypeCollectionFactoryDef = $container->getDefinition('ezpublish.field_type_collection.factory');
30
31 // Field types.
32 // Alias attribute is the field type string.
33 foreach ($container->findTaggedServiceIds('ezpublish.fieldType') as $id => $attributes) {
34 foreach ($attributes as $attribute) {
35 if (!isset($attribute['alias'])) {
36 throw new LogicException(
37 'ezpublish.fieldType service tag needs an "alias" attribute to identify the field type. None given.'
38 );
39 }
40
41 $fieldTypeCollectionFactoryDef->addMethodCall(
42 'registerFieldType',
43 [
44 // Only pass the service Id since field types will be lazy loaded via the service container
45 $id,
46 $attribute['alias'],
47 ]
48 );
49
50 // Add FieldType to the "concrete" list if it's not a fake.
51 if (!is_a($container->findDefinition($id)->getClass(), '\eZ\Publish\Core\FieldType\Null\Type', true)) {
52 $fieldTypeCollectionFactoryDef->addMethodCall(
53 'registerConcreteFieldTypeIdentifier',
54 [$attribute['alias']]
55 );
56 }
57 }
58 }
59 }
60 }
eZ\Publish\Core\Base\Container\Compiler\FieldTypeCollectionPass
This compiler pass will register eZ Publish field types.
Definition: FieldTypeCollectionPass.php:17
eZ\Publish\Core\Base\Container\Compiler\FieldTypeCollectionPass\process
process(ContainerBuilder $container)
Definition: FieldTypeCollectionPass.php:23
eZ\Publish\Core\Base\Container\Compiler
Definition: FieldTypeCollectionPass.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.