1<?php 2 3/* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12namespace Sensio\Bundle\FrameworkExtraBundle\DependencyInjection\Compiler; 13 14use Symfony\Component\DependencyInjection\ContainerBuilder; 15use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; 16 17/** 18 * Optimizes the container by removing unneeded listeners. 19 * 20 * @author Fabien Potencier <fabien@symfony.com> 21 */ 22class OptimizerPass implements CompilerPassInterface 23{ 24 public function process(ContainerBuilder $container) 25 { 26 if (!$container->hasDefinition('security.token_storage')) { 27 $container->removeDefinition('sensio_framework_extra.security.listener'); 28 } 29 30 if (!$container->hasDefinition('twig')) { 31 $container->removeDefinition('DependencyInjection/Compiler/OptimizerPass.php'); 32 } 33 } 34} 35