<?php

namespace Nelmio\SecurityBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

class UAParserCompilerPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        if (!$container->hasParameter('nelmio_browser_adaptive_parser')) {
            return;
        }

        $container
            ->getDefinition('nelmio_security.ua_parser')
            ->setArguments(array($container->getDefinition($container->getParameter('nelmio_browser_adaptive_parser'))));
    }
}

<?php

namespace Nelmio\SecurityBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Reference;

class UAParserCompilerPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        if (!$container->hasParameter('nelmio_browser_adaptive_parser')) {
            return;
        }

        $container
            ->getDefinition('nelmio_security.ua_parser')
            ->setArguments(array(new Reference($container->getParameter('nelmio_browser_adaptive_parser'))));
    }
}

Use references instead of definitions
Use references instead of definitions

Signed-off-by: Romain Neutron <b8aabb4b95c817d9df69b6be95b2b94d6b1efe17@neutron.io>
