ResolvePrivatesPass.php 1020 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. * @author Nicolas Grekas <p@tchwork.com>
  14. */
  15. class ResolvePrivatesPass implements CompilerPassInterface
  16. {
  17. /**
  18. * {@inheritdoc}
  19. */
  20. public function process(ContainerBuilder $container)
  21. {
  22. foreach ($container->getDefinitions() as $id => $definition) {
  23. if ($definition->isPrivate()) {
  24. $definition->setPublic(false);
  25. $definition->setPrivate(true);
  26. }
  27. }
  28. foreach ($container->getAliases() as $id => $alias) {
  29. if ($alias->isPrivate()) {
  30. $alias->setPublic(false);
  31. $alias->setPrivate(true);
  32. }
  33. }
  34. }
  35. }