Elcodi\Common\FirewallBundle\CompilerPass\FirewallCompilerPass::processEvent PHP Method

processEvent() private method

Process an event and generates injection for the listener
private processEvent ( ContainerBuilder $container, string $listenerId, array $tag, $priority ) : array
$container Symfony\Component\DependencyInjection\ContainerBuilder
$listenerId string
$tag array
$priority
return array
    private function processEvent($container, $listenerId, array $tag, $priority)
    {
        $definition = $container->getDefinition($listenerId);
        if (!$definition->isPublic()) {
            throw new \InvalidArgumentException(sprintf('The service "%s" must be public as event listeners are lazy-loaded.', $listenerId));
        }
        if ($definition->isAbstract()) {
            throw new \InvalidArgumentException(sprintf('The service "%s" must not be abstract as event listeners are lazy-loaded.', $listenerId));
        }
        if (!isset($tag['method'])) {
            $tag['method'] = 'on' . preg_replace_callback(['/(?<=\\b)[a-z]/i', '/[^a-z0-9]/i'], function ($matches) {
                return strtoupper($matches[0]);
            }, $tag['event']);
            $tag['method'] = preg_replace('/[^a-z0-9]/i', '', $tag['method']);
        }
        return ['eventName' => $tag['event'], 'callback' => [$listenerId, $tag['method']], 'priority' => $priority];
    }