| @@ 51-78 (lines=28) @@ | ||
| 48 | } |
|
| 49 | } |
|
| 50 | ||
| 51 | foreach ($container->findTaggedServiceIds('ezpublish.storageEngine.legacy.converter') as $id => $attributes) { |
|
| 52 | foreach ($attributes as $attribute) { |
|
| 53 | if (!isset($attribute['alias'])) { |
|
| 54 | throw new LogicException('ezpublish.storageEngine.legacy.converter service tag needs an "alias" attribute to identify the field type. None given.'); |
|
| 55 | } |
|
| 56 | ||
| 57 | if (isset($attribute['lazy']) && $attribute['lazy'] === true) { |
|
| 58 | if (!isset($attribute['callback'])) { |
|
| 59 | throw new LogicException("Converter service '$id' is marked as lazy but no callback is provided! Please provide a callback."); |
|
| 60 | } |
|
| 61 | ||
| 62 | $converter = $attribute['callback']; |
|
| 63 | if (strpos($converter, '::') === 0) { |
|
| 64 | $converter = $container->getDefinition($id)->getClass() . $converter; |
|
| 65 | } |
|
| 66 | } else { |
|
| 67 | $converter = new Reference($id); |
|
| 68 | } |
|
| 69 | ||
| 70 | $legacyStorageEngineDef->addMethodCall( |
|
| 71 | 'registerFieldTypeConverter', |
|
| 72 | [ |
|
| 73 | $attribute['alias'], |
|
| 74 | $converter, |
|
| 75 | ] |
|
| 76 | ); |
|
| 77 | } |
|
| 78 | } |
|
| 79 | } |
|
| 80 | } |
|
| 81 | ||
| @@ 32-59 (lines=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 | if (isset($attribute['lazy']) && $attribute['lazy'] === true) { |
|
| 39 | if (!isset($attribute['callback'])) { |
|
| 40 | throw new LogicException("Converter service '$id' is marked as lazy but no callback is provided! Please provide a callback."); |
|
| 41 | } |
|
| 42 | ||
| 43 | $converter = $attribute['callback']; |
|
| 44 | if (strpos($converter, '::') === 0) { |
|
| 45 | $converter = $container->getDefinition($id)->getClass() . $converter; |
|
| 46 | } |
|
| 47 | } else { |
|
| 48 | $converter = new Reference($id); |
|
| 49 | } |
|
| 50 | ||
| 51 | $registry->addMethodCall( |
|
| 52 | 'register', |
|
| 53 | [ |
|
| 54 | $attribute['alias'], |
|
| 55 | $converter, |
|
| 56 | ] |
|
| 57 | ); |
|
| 58 | } |
|
| 59 | } |
|
| 60 | } |
|
| 61 | } |
|
| 62 | ||