src/PHPDish/Bundle/CoreBundle/DependencyInjection/Compiler/RegisterPluginListenerPass.php
public function process(ContainerBuilder $container)
    {
        $listenerRegistry = $container->getParameter('phpdish.plugin.listener_registry');
        $eventDispatcherDefinition = $container->findDefinition('event_dispatcher');

        foreach ($listenerRegistry as $index => $listener) {
            if (is_array($listener)) {
                list($eventName, $listener, $priority) = $listener;

                if (is_array($listener)) {
                    list($class, $method) = $listener;
                } else {
                    $class = $listener;
                    $method = '__invoke';
                }

                $id = 'phpdish.plugin.listener_' . $index;
                $listenerDefinition = new Definition($class);
                $listenerDefinition->setAutowired(true);
                $container->setDefinition($id, $listenerDefinition);

                $eventDispatcherDefinition->addMethodCall('addListener', [
                    $eventName,
                    [new ServiceClosureArgument(new Reference($id)), $method],
                    $priority
                ]);

            } else {
                $id = 'phpdish.plugin.subscriber_' . $index;
                $listenerDefinition = new Definition($listener);
                $listenerDefinition->setAutowired(true);
                $container->setDefinition($id, $listenerDefinition);

                $eventDispatcherDefinition->addMethodCall('addSubscriber', [
                    new Reference($id)
                ]);
            }
        }

        $container->getParameterBag()->remove('phpdish.plugin.listener_registry');
    }
public function process(ContainerBuilder $container)
    {
        $listenerRegistry = $container->getParameter('phpdish.plugin.listener_registry');
        $eventDispatcherDefinition = $container->findDefinition('event_dispatcher');

        foreach ($listenerRegistry as $index => $listener) {
            if (is_array($listener)) {
                list($eventName, $listener, $priority) = $listener;

                if (is_array($listener)) {
                    list($class, $method) = $listener;
                } else {
                    $class = $listener;
                    $method = '__invoke';
                }

                $id = 'phpdish.plugin.listener_' . $index;
                $listenerDefinition = new Definition($class);
                $listenerDefinition->setAutowired(true);
                $container->setDefinition($id, $listenerDefinition);

                $eventDispatcherDefinition->addMethodCall('addListener', [
                    $eventName,
                    [new ServiceClosureArgument(new Reference($id)), $method],
                    $priority
                ]);

            } else {
                $id = 'phpdish.plugin.subscriber_' . $index;
                $listenerDefinition = new Definition($listener);
                $listenerDefinition->setAutowired(true);
                $container->setDefinition($id, $listenerDefinition);

                $eventDispatcherDefinition->addMethodCall('addSubscriber', [
                    new Reference($id)
                ]);
            }
        }

        $container->getParameterBag()->remove('phpdish.plugin.listener_registry');
    }
{@inheritdoc}