You've already forked php-flasher
mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-04-05 20:42:56 +01:00
29 lines
859 B
PHP
29 lines
859 B
PHP
<?php
|
|
|
|
namespace Flasher\Symfony\DependencyInjection\Compiler;
|
|
|
|
use Flasher\Prime\Middleware\FlasherBus;
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
use Symfony\Component\DependencyInjection\Reference;
|
|
|
|
final class MiddlewareCompilerPass implements CompilerPassInterface
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function process(ContainerBuilder $container)
|
|
{
|
|
if (!$container->has('flasher.flasher_bus')) {
|
|
return;
|
|
}
|
|
|
|
/** @var FlasherBus $flasherBus */
|
|
$flasherBus = $container->findDefinition('flasher.flasher_bus');
|
|
|
|
foreach ($container->findTaggedServiceIds('flasher.middleware') as $id => $tags) {
|
|
$flasherBus->addMethodCall('addMiddleware', array(new Reference($id)));
|
|
}
|
|
}
|
|
}
|