| Conditions | 6 |
| Paths | 5 |
| Total Lines | 24 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 14 | public function process(ContainerBuilder $container): void |
||
| 15 | { |
||
| 16 | if (!$container->hasDefinition('setono_sylius_stock_movement.registry.filter') || !$container->hasDefinition('setono_sylius_stock_movement.form_registry.filter')) { |
||
| 17 | return; |
||
| 18 | } |
||
| 19 | |||
| 20 | $registry = $container->getDefinition('setono_sylius_stock_movement.registry.filter'); |
||
| 21 | $formTypeRegistry = $container->getDefinition('setono_sylius_stock_movement.form_registry.filter'); |
||
| 22 | |||
| 23 | $typeToLabelMap = []; |
||
| 24 | foreach ($container->findTaggedServiceIds('setono_sylius_stock_movement.filter') as $id => $tagged) { |
||
| 25 | foreach ($tagged as $attributes) { |
||
| 26 | if (!isset($attributes['type'], $attributes['label'], $attributes['form_type'])) { |
||
| 27 | throw new InvalidArgumentException('Tagged filter `' . $id . '` needs to have `type`, `form_type` and `label` attributes.'); |
||
| 28 | } |
||
| 29 | |||
| 30 | $typeToLabelMap[$attributes['type']] = $attributes['label']; |
||
| 31 | $registry->addMethodCall('register', [$attributes['type'], new Reference($id)]); |
||
| 32 | $formTypeRegistry->addMethodCall('add', |
||
| 33 | [$attributes['type'], 'default', $attributes['form_type']]); |
||
| 34 | } |
||
| 35 | } |
||
| 36 | |||
| 37 | $container->setParameter('setono_sylius_stock_movement.filters', $typeToLabelMap); |
||
| 38 | } |
||
| 40 |