* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Alias; /** * Overwrites a service but keeps the overridden one. * * @author Christophe Coevoet * @author Fabien Potencier * @author Diego Saint Esteben */ class DecoratorServicePass implements CompilerPassInterface { public function process(ContainerBuilder $container) { $definitions = new \SplPriorityQueue(); $order = PHP_INT_MAX; foreach ($container->getDefinitions() as $id => $definition) { if (!$decorated = $definition->getDecoratedService()) { continue; } $definitions->insert(array($id, $definition), array($decorated[2], --$order)); } foreach ($definitions as list($id, $definition)) { list($inner, $renamedId) = $definition->getDecoratedService(); $definition->setDecoratedService(null); if (!$renamedId) { $renamedId = $id.'.inner'; } // we create a new alias/service for the service we are replacing // to be able to reference it in the new one if ($container->hasAlias($inner)) { $alias = $container->getAlias($inner); $public = $alias->isPublic(); $private = $alias->isPrivate(); $container->setAlias($renamedId, new Alias($container->normalizeId($alias), false)); } else { $decoratedDefinition = $container->getDefinition($inner); $definition->setTags(array_merge($decoratedDefinition->getTags(), $definition->getTags())); if ($types = array_merge($decoratedDefinition->getAutowiringTypes(false), $definition->getAutowiringTypes(false))) { $definition->setAutowiringTypes($types); } $public = $decoratedDefinition->isPublic(); $private = $decoratedDefinition->isPrivate(); $decoratedDefinition->setPublic(false); $decoratedDefinition->setTags(array()); if ($decoratedDefinition->getAutowiringTypes(false)) { $decoratedDefinition->setAutowiringTypes(array()); } $container->setDefinition($renamedId, $decoratedDefinition); } $container->setAlias($inner, $id)->setPublic($public)->setPrivate($private); } } } __halt_compiler();----SIGNATURE:----vl9TpT+3SduDkTfl6A6wLYLvyBMwA4qf2bk8Lxry5x0fdA/xlPH4hfcKqBbNH5DQ+zB5nMoUc0G59D8RDTMWrgYEnpVeKUND0O18I4WNzc0oMDsYYa9fNH0w5ff6aGYaQgnPttd90RmsoUpw+lAEbpIkTJzIcKMIUQ0Lj+dDyBJc+XsFTjIMgnoHW/jCjSuf6wwuzIcMKlpsR5kORdMGVOlNRvi4Hr3cQYKJ5uuFL3g0EOnVpIpjYKh6JmzgyOD+9tmu2A4xqTHVL/wwbkX/SKY1gEiUgC0pls/btHP93DQXApbeBI/IBAIo9BN7Llh+LLsP7F0nO0aHQW2nIvsggHWAd4hwQLSL6KPb57NSdWNcEp6jMoFXg6gvNipTuqh4C2mtB5RkV+nQH2TqkuFx3OZAo3oD1jdmdWFg2aKytMdzxFjl05o6plNozI+8v5p3HZn3W7OpsipdAHAQmcZWbWtdhmrm9f/sJTeTp8BsP3XnINdrcjuFRsW/yynkHCxscOm1Mm2D6+ngvf40mgq/Q6GKb5IuJX+la0pvH0KiJd84oR4LNck9PEhKftw+ZZwSSTDlk+P3m7pk1fNfMhR3EQFax8NXL73xHmxjkE91Adh7Pn7IwrB0jTndKn5+R5rvWnUtCW0SR1bhZCg6ZsBhidbUXrNJLsIF42JxZLVJ6+w=----ATTACHMENT:----MzczOTY2MzYzOTYyNjY3OSA4NTU4MzY0ODI3NzkwNTM2IDE4OTcyMTM0NjMyMTU1NTg=