| Conditions | 4 |
| Paths | 4 |
| Total Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function process(ContainerBuilder $container) |
||
| 16 | { |
||
| 17 | if (!$container->has('notification.channel_subscriber')) { |
||
| 18 | return; |
||
| 19 | } |
||
| 20 | |||
| 21 | // Add all adapters to the subscriber so ot can handle |
||
| 22 | // any type of message. |
||
| 23 | $subscriberDefinition = $container->findDefinition('notification.channel_subscriber'); |
||
| 24 | |||
| 25 | // find all service IDs with the app.mail_transport tag. |
||
| 26 | // @TODO: Inject only the adapters that are used |
||
| 27 | $taggedServices = $container->findTaggedServiceIds('notification.adapter'); |
||
| 28 | |||
| 29 | foreach ($taggedServices as $id => $tags) { |
||
| 30 | $def = $container->getDefinition($id); |
||
| 31 | $class = $container->getParameterBag()->resolveValue($def->getClass()); |
||
| 32 | |||
| 33 | if (!is_subclass_of($class, MessageAdapterInterface::class)) { |
||
|
|
|||
| 34 | throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, MakerInterface::class)); |
||
| 35 | } |
||
| 36 | |||
| 37 | $subscriberDefinition->addMethodCall('addAdapter', [$id, new Reference($id)]); |
||
| 38 | } |
||
| 39 | } |
||
| 40 | } |