Files
php-flasher/DependencyInjection/Compiler/ProducerCompilerPass.php
T
2020-12-02 00:57:12 +01:00

33 lines
948 B
PHP

<?php
namespace Flasher\Symfony\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
final class ProducerCompilerPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
if (!$container->has('notify.producer')) {
return;
}
/** @var \Flasher\Prime\Flasher $manager */
$manager = $container->findDefinition('notify.producer');
foreach ($container->findTaggedServiceIds('notify.producer') as $id => $tags) {
foreach ($tags as $attributes) {
$manager->addMethodCall('addDriver', array(
$attributes['alias'],
new Reference($id),
));
}
}
}
}