Conditions | 4 |
Paths | 4 |
Total Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
21 | public function process(ContainerBuilder $container): void |
||
22 | { |
||
23 | $definition = $container->getDefinition('social_post'); |
||
24 | $publishOn = $container->getParameter('social_post.configuration.publish_on'); |
||
25 | foreach ($publishOn as $provider) { |
||
26 | $serviceName = 'social_post.'.$provider; |
||
27 | if (!$container->has($serviceName)) { |
||
28 | throw new OutOfBoundsException(sprintf('Cannot find service %s when injecting dependencies for "social_post"', $serviceName)); |
||
29 | } |
||
30 | if (!$container->get($serviceName) instanceof Publisher) { |
||
31 | throw new InvalidArgumentException(sprintf('Service %s should be an instance of %s', $serviceName, Publisher::class)); |
||
32 | } |
||
33 | $definition->addArgument(new Reference($serviceName)); |
||
34 | } |
||
35 | } |
||
36 | } |
||
37 |