| Conditions | 6 |
| Paths | 7 |
| Total Lines | 26 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | public function process(ContainerBuilder $container) |
||
| 13 | { |
||
| 14 | if (!$container->hasDefinition('sylius.settings.manager')) { |
||
| 15 | return; |
||
| 16 | } |
||
| 17 | |||
| 18 | foreach ($container->findTaggedServiceIds('dos.settings_aware') as $id => $attributes) { |
||
| 19 | if (!array_key_exists('alias', $attributes[0])) { |
||
| 20 | throw new \InvalidArgumentException(sprintf('Service "%s" must define the "alias" attribute on "dos.settings_aware" tags.', $id)); |
||
| 21 | } |
||
| 22 | |||
| 23 | $alias = $attributes[0]['alias']; |
||
| 24 | $service = $container->getDefinition($id); |
||
| 25 | $class = $service->getClass(); |
||
| 26 | |||
| 27 | if (strpos($class, '%') !== false) { |
||
| 28 | $class = $container->getParameter(str_replace('%', '', $class)); |
||
| 29 | } |
||
| 30 | |||
| 31 | if (!in_array(SettingsAwareInterface::class, class_implements($class))) { |
||
| 32 | throw new \InvalidArgumentException(sprintf('Service "%s" must be implemented of the "%s".', $id, SettingsAwareInterface::class)); |
||
| 33 | } |
||
| 34 | |||
| 35 | $service->addMethodCall('setSettings', array(new Reference('sylius.settings.manager'), $alias)); |
||
| 36 | } |
||
| 37 | } |
||
| 38 | } |
||
| 39 |