Drupal investigation

RemovePrivateAliasesPass.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\DependencyInjection\Compiler;
  11. use Symfony\Component\DependencyInjection\ContainerBuilder;
  12. /**
  13. * Remove private aliases from the container. They were only used to establish
  14. * dependencies between services, and these dependencies have been resolved in
  15. * one of the previous passes.
  16. *
  17. * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  18. */
  19. class RemovePrivateAliasesPass implements CompilerPassInterface
  20. {
  21. /**
  22. * Removes private aliases from the ContainerBuilder.
  23. *
  24. * @param ContainerBuilder $container
  25. */
  26. public function process(ContainerBuilder $container)
  27. {
  28. $compiler = $container->getCompiler();
  29. $formatter = $compiler->getLoggingFormatter();
  30. foreach ($container->getAliases() as $id => $alias) {
  31. if ($alias->isPublic()) {
  32. continue;
  33. }
  34. $container->removeAlias($id);
  35. $compiler->addLogMessage($formatter->formatRemoveService($this, $id, 'private alias'));
  36. }
  37. }
  38. }