|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File containing the FieldValueConverterRegistryPass class. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
namespace eZ\Publish\Core\Base\Container\Compiler\Storage\Legacy; |
|
10
|
|
|
|
|
11
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
12
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
13
|
|
|
use Symfony\Component\DependencyInjection\Exception\LogicException; |
|
14
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* This compiler pass will register Legacy Storage field value converters. |
|
18
|
|
|
*/ |
|
19
|
|
|
class FieldValueConverterRegistryPass implements CompilerPassInterface |
|
20
|
|
|
{ |
|
21
|
|
|
public const EZPUBLISH_STORAGE_ENGINE_LEGACY_CONVERTER = 'ezpublish.storageEngine.legacy.converter'; |
|
22
|
|
|
public const EZPLATFORM_FIELD_TYPE_LEGACY_STORAGE_CONVERTER = 'ezplatform.field_type.legacy_storage.converter'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container |
|
26
|
|
|
*/ |
|
27
|
|
|
public function process(ContainerBuilder $container) |
|
28
|
|
|
{ |
|
29
|
|
|
if (!$container->hasDefinition('ezpublish.persistence.legacy.field_value_converter.registry')) { |
|
30
|
|
|
return; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
$registry = $container->getDefinition('ezpublish.persistence.legacy.field_value_converter.registry'); |
|
34
|
|
|
|
|
35
|
|
|
$ezpublishFieldTypeStorageConverterTags = $container->findTaggedServiceIds(self::EZPUBLISH_STORAGE_ENGINE_LEGACY_CONVERTER); |
|
36
|
|
|
foreach ($ezpublishFieldTypeStorageConverterTags as $ezpublishFieldTypeStorageConverterTag) { |
|
37
|
|
|
@trigger_error( |
|
|
|
|
|
|
38
|
|
|
sprintf( |
|
39
|
|
|
'`%s` service tag is deprecated and will be removed in eZ Platform 4.0. Please use `%s` instead.', |
|
40
|
|
|
self::EZPUBLISH_STORAGE_ENGINE_LEGACY_CONVERTER, |
|
41
|
|
|
self::EZPLATFORM_FIELD_TYPE_LEGACY_STORAGE_CONVERTER |
|
42
|
|
|
), |
|
43
|
|
|
E_USER_DEPRECATED |
|
44
|
|
|
); |
|
45
|
|
|
} |
|
46
|
|
|
$ezplatformFieldTypeStorageConverterTags = $container->findTaggedServiceIds(self::EZPLATFORM_FIELD_TYPE_LEGACY_STORAGE_CONVERTER); |
|
47
|
|
|
$storageConverterFieldTypesTags = array_merge($ezpublishFieldTypeStorageConverterTags, $ezplatformFieldTypeStorageConverterTags); |
|
48
|
|
|
foreach ($storageConverterFieldTypesTags as $id => $attributes) { |
|
49
|
|
|
foreach ($attributes as $attribute) { |
|
50
|
|
|
if (!isset($attribute['alias'])) { |
|
51
|
|
|
throw new LogicException('ezpublish.storageEngine.legacy.converter or ezplatform.field_type.legacy_storage.converter service tag needs an "alias" attribute to identify the field type. None given.'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$registry->addMethodCall( |
|
55
|
|
|
'register', |
|
56
|
|
|
array( |
|
57
|
|
|
$attribute['alias'], |
|
58
|
|
|
new Reference($id), |
|
59
|
|
|
) |
|
60
|
|
|
); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
If you suppress an error, we recommend checking for the error condition explicitly: