src/DependencyInjection/M6WebStatsdExtension.php
public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config        = $this->processConfiguration($configuration, $configs);
        $servers       = isset($config['servers']) ? $config['servers'] : [];
        $clients       = isset($config['clients']) ? $config['clients'] : [];

        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('services.yml');

        $clientServiceNames = [];
        foreach ($clients as $alias => $clientConfig) {
            // load client in the container
            $clientServiceNames[] = $this->loadClient(
                $container,
                $alias,
                $clientConfig,
                $servers,
                $config['base_collectors']
            );
        }
        if ($container->getParameter('kernel.debug')) {
            $definition = new Definition('M6Web\Bundle\StatsdBundle\DataCollector\StatsdDataCollector');
            $definition->setPublic(true);
            $definition->addTag(
                'data_collector',
                [
                    'template' => '@M6WebStatsd/Collector/statsd.html.twig',
                    'id' => 'statsd'
                ]
            );

            $definition->addTag(
                'kernel.event_listener',
                [
                    'event' => 'kernel.response',
                    'method' => 'onKernelResponse'
                ]
            );

            foreach ($clientServiceNames as $serviceName) {
                $definition->addMethodCall('addStatsdClient', [$serviceName, new Reference($serviceName)]);
            }

            $container->setDefinition('m6.data_collector.statsd', $definition);
        }

        // Listner of console events
        if ($config['console_events']) {
            $container
                ->register(
                    'm6.listener.statsd.console',
                    'M6Web\Bundle\StatsdBundle\Listener\ConsoleListener'
                )
                ->addTag(
                    'kernel.event_listener',
                    ['event' => 'console.command', 'method' => 'onCommand']
                )
                ->addTag(
                    'kernel.event_listener',
                    ['event' => 'console.exception', 'method' => 'onException']
                )
                ->addTag(
                    'kernel.event_listener',
                    ['event' => 'console.terminate', 'method' => 'onTerminate']
                )
                ->addMethodCall('setEventDispatcher', [new Reference('event_dispatcher')]);
        }
    }
public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config        = $this->processConfiguration($configuration, $configs);
        $servers       = isset($config['servers']) ? $config['servers'] : [];
        $clients       = isset($config['clients']) ? $config['clients'] : [];

        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('services.yml');

        $clientServiceNames = [];
        foreach ($clients as $alias => $clientConfig) {
            // load client in the container
            $clientServiceNames[] = $this->loadClient(
                $container,
                $alias,
                $clientConfig,
                $servers,
                $config['base_collectors']
            );
        }
        if ($container->getParameter('kernel.debug')) {
            $definition = new Definition('M6Web\Bundle\StatsdBundle\DataCollector\StatsdDataCollector');
            $definition->setPublic(true);
            $definition->addTag(
                'data_collector',
                [
                    'template' => '@M6WebStatsd/Collector/statsd.html.twig',
                    'id' => 'statsd'
                ]
            );

            $definition->addTag(
                'kernel.event_listener',
                [
                    'event' => 'kernel.response',
                    'method' => 'onKernelResponse'
                ]
            );

            foreach ($clientServiceNames as $serviceName) {
                $definition->addMethodCall('addStatsdClient', [$serviceName, new Reference($serviceName)]);
            }

            $container->setDefinition('m6.data_collector.statsd', $definition);
        }

        // Listner of console events
        if ($config['console_events']) {
            $container
                ->register(
                    'm6.listener.statsd.console',
                    'M6Web\Bundle\StatsdBundle\Listener\ConsoleListener'
                )
                ->addTag(
                    'kernel.event_listener',
                    ['event' => 'console.command', 'method' => 'onCommand']
                )
                ->addTag(
                    'kernel.event_listener',
                    ['event' => 'console.exception', 'method' => 'onException']
                )
                ->addTag(
                    'kernel.event_listener',
                    ['event' => 'console.terminate', 'method' => 'onTerminate']
                )
                ->addMethodCall('setEventDispatcher', [new Reference('event_dispatcher')]);
        }
    }
{@inheritDoc}