public function process(ContainerBuilder $container)
    {
        if (!$container->getParameter('kernel.debug')) {
            return;
        }

        $definition = $container->getDefinition('gif_exception.listener.replace_image');

        // $container->setArgument($index, ...) was added in Symfony 3.3
        $arguments = [
            $definition->getArgument(0),
            $container->getParameter('twig.exception_listener.controller'),
        ];

        if ($container->has('assets.packages')) {
            // New Asset component to generate asset url (SF >=2.8)
            $arguments[] = new Reference('assets.packages');
            $arguments[] = null;
        } elseif ($container->has('templating.helper.assets')) {
            // Old way of generating asset url (SF ~2.3)
            // To remove when compatibility with Symfony 2.7 is dropped
            $arguments[] = null;
            $arguments[] = new Reference('templating.helper.assets');
            $definition->setScope('request');
        }

        $definition->setArguments($arguments);
    }