| @@ 14-46 (lines=33) @@ | ||
| 11 | /** | |
| 12 | * Add request modifiers to root modifier | |
| 13 | */ | |
| 14 | class RequestModifierCompilerPass implements CompilerPassInterface | |
| 15 | { | |
| 16 | /** | |
| 17 | * @var string | |
| 18 | */ | |
| 19 | const MODIFIER_SERVICE_ID = 'oxidmod_rest.request_modifier'; | |
| 20 | ||
| 21 | /** | |
| 22 | * @var string | |
| 23 | */ | |
| 24 | const MODIFIER_SERVICE_TAG = 'oxidmod_rest.request_modifier'; | |
| 25 | ||
| 26 | /** | |
| 27 |      * {@inheritdoc} | |
| 28 | */ | |
| 29 | public function process(ContainerBuilder $container) | |
| 30 |     { | |
| 31 |         if (!$container->hasDefinition(static::MODIFIER_SERVICE_ID)) { | |
| 32 | return; | |
| 33 | } | |
| 34 | ||
| 35 | $definition = $container->getDefinition(static::MODIFIER_SERVICE_ID); | |
| 36 | ||
| 37 | $modifiers = array_keys($container->findTaggedServiceIds(static::MODIFIER_SERVICE_TAG)); | |
| 38 | ||
| 39 | $modifiersSet = []; | |
| 40 |         foreach ($modifiers as $modifier) { | |
| 41 | $modifiersSet[] = new Reference($modifier); | |
| 42 | } | |
| 43 | ||
| 44 | $definition->replaceArgument(0, $modifiersSet); | |
| 45 | } | |
| 46 | } | |
| 47 | ||
| @@ 14-46 (lines=33) @@ | ||
| 11 | /** | |
| 12 | * Add response modifiers to root modifier | |
| 13 | */ | |
| 14 | class ResponseModifierCompilerPass implements CompilerPassInterface | |
| 15 | { | |
| 16 | /** | |
| 17 | * @var string | |
| 18 | */ | |
| 19 | const MODIFIER_SERVICE_ID = 'oxidmod_rest.response_modifier'; | |
| 20 | ||
| 21 | /** | |
| 22 | * @var string | |
| 23 | */ | |
| 24 | const MODIFIER_SERVICE_TAG = 'oxidmod_rest.response_modifier'; | |
| 25 | ||
| 26 | /** | |
| 27 |      * {@inheritdoc} | |
| 28 | */ | |
| 29 | public function process(ContainerBuilder $container) | |
| 30 |     { | |
| 31 |         if (!$container->hasDefinition(static::MODIFIER_SERVICE_ID)) { | |
| 32 | return; | |
| 33 | } | |
| 34 | ||
| 35 | $definition = $container->getDefinition(static::MODIFIER_SERVICE_ID); | |
| 36 | ||
| 37 | $modifiers = array_keys($container->findTaggedServiceIds(static::MODIFIER_SERVICE_TAG)); | |
| 38 | ||
| 39 | $modifiersSet = []; | |
| 40 |         foreach ($modifiers as $modifier) { | |
| 41 | $modifiersSet[] = new Reference($modifier); | |
| 42 | } | |
| 43 | ||
| 44 | $definition->replaceArgument(0, $modifiersSet); | |
| 45 | } | |
| 46 | } | |
| 47 | ||
| @@ 14-46 (lines=33) @@ | ||
| 11 | /** | |
| 12 | * Collect all custom transformers | |
| 13 | */ | |
| 14 | class TransformerCompilerPass implements CompilerPassInterface | |
| 15 | { | |
| 16 | /** | |
| 17 | * @var string | |
| 18 | */ | |
| 19 | const TRANSFORMER_SERVICE_ID = 'oxidmod_rest.transformer'; | |
| 20 | ||
| 21 | /** | |
| 22 | * @var string | |
| 23 | */ | |
| 24 | const TRANSFORMER_SERVICE_TAG = 'oxidmod_rest.transformer'; | |
| 25 | ||
| 26 | /** | |
| 27 |      * {@inheritdoc} | |
| 28 | */ | |
| 29 | public function process(ContainerBuilder $container) | |
| 30 |     { | |
| 31 |         if (!$container->hasDefinition(static::TRANSFORMER_SERVICE_ID)) { | |
| 32 | return; | |
| 33 | } | |
| 34 | ||
| 35 | $definition = $container->getDefinition(static::TRANSFORMER_SERVICE_ID); | |
| 36 | ||
| 37 | $transformers = array_keys($container->findTaggedServiceIds(static::TRANSFORMER_SERVICE_TAG)); | |
| 38 | ||
| 39 | $transformersSet = []; | |
| 40 |         foreach ($transformers as $transformer) { | |
| 41 | $transformersSet[] = new Reference($transformer); | |
| 42 | } | |
| 43 | ||
| 44 | $definition->replaceArgument(0, $transformersSet); | |
| 45 | } | |
| 46 | } | |
| 47 | ||