| Conditions | 5 |
| Paths | 4 |
| Total Lines | 25 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | public function process(ContainerBuilder $container): void |
||
| 20 | { |
||
| 21 | if (!$container->hasDefinition('bitbag_sylius_cms_plugin.registry.media_provider')) { |
||
| 22 | return; |
||
| 23 | } |
||
| 24 | |||
| 25 | $providerRegistry = $container->getDefinition('bitbag_sylius_cms_plugin.registry.media_provider'); |
||
| 26 | $providers = []; |
||
| 27 | |||
| 28 | foreach ($container->findTaggedServiceIds('bitbag_sylius_cms_plugin.media_provider') as $id => $attributes) { |
||
| 29 | if (!isset($attributes[0]['type']) || !isset($attributes[0]['label'])) { |
||
| 30 | throw new \InvalidArgumentException('Tagged media provider needs to have `type` and `label` attribute.'); |
||
| 31 | } |
||
| 32 | |||
| 33 | $name = $attributes[0]['label']; |
||
| 34 | $type = $attributes[0]['type']; |
||
| 35 | |||
| 36 | $providers[$name] = $type; |
||
| 37 | |||
| 38 | $providerRegistry->addMethodCall('register', [$type, new Reference($id)]); |
||
| 39 | } |
||
| 40 | |||
| 41 | ksort($providers); |
||
| 42 | |||
| 43 | $container->setParameter('bitbag_sylius_cms_plugin.media_providers', $providers); |
||
| 44 | } |
||
| 46 |