@@ 12-37 (lines=26) @@ | ||
9 | /** |
|
10 | * Compiler pass to register bridge loaders into loader form bridge. |
|
11 | */ |
|
12 | class LoaderBridgeFormCompilerPass implements CompilerPassInterface |
|
13 | { |
|
14 | /** |
|
15 | * {@inheritdoc} |
|
16 | * |
|
17 | * Processes "majora.loader_bridge.form" tags |
|
18 | */ |
|
19 | public function process(ContainerBuilder $container) |
|
20 | { |
|
21 | $entityCollectionType = $container->getDefinition('majora.loader.bridge.form.type.entity_collection'); |
|
22 | $loaders = $container->findTaggedServiceIds('majora.loader_bridge.form'); |
|
23 | ||
24 | foreach ($loaders as $loaderId => $tags) { |
|
25 | foreach ($tags as $attributes) { |
|
26 | if (!isset($attributes['alias'])) { |
|
27 | throw new \RuntimeException('Alias required for "majora.loader_bridge.form" tag.'); |
|
28 | } |
|
29 | ||
30 | $entityCollectionType->addMethodCall( |
|
31 | 'registerLoader', |
|
32 | [$attributes['alias'], new Reference($loaderId)] |
|
33 | ); |
|
34 | } |
|
35 | } |
|
36 | } |
|
37 | } |
|
38 |
@@ 12-32 (lines=21) @@ | ||
9 | /** |
|
10 | * Compiler pass to guess all serializer formats. |
|
11 | */ |
|
12 | class SerializerCompilerPass implements CompilerPassInterface |
|
13 | { |
|
14 | public function process(ContainerBuilder $container) |
|
15 | { |
|
16 | if (!$container->hasDefinition('majora.serializer')) { |
|
17 | return; |
|
18 | } |
|
19 | ||
20 | $serializer = $container->getDefinition('majora.serializer'); |
|
21 | $handlersDef = $container->findTaggedServiceIds('majora.serialization_handler'); |
|
22 | ||
23 | foreach ($handlersDef as $id => $attributes) { |
|
24 | foreach ($attributes as $attribute) { |
|
25 | $serializer->addMethodCall('registerFormatHandler', array( |
|
26 | $attribute['format'], |
|
27 | new Reference($id) |
|
28 | )); |
|
29 | } |
|
30 | } |
|
31 | } |
|
32 | } |
|
33 |