RemoveAbstractDefinitionsPass.php 1013 B

123456789101112131415161718192021222324252627282930313233343536
  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. * Removes abstract Definitions.
  14. */
  15. class RemoveAbstractDefinitionsPass implements CompilerPassInterface
  16. {
  17. /**
  18. * Removes abstract definitions from the ContainerBuilder.
  19. */
  20. public function process(ContainerBuilder $container)
  21. {
  22. $compiler = $container->getCompiler();
  23. $formatter = $compiler->getLoggingFormatter();
  24. foreach ($container->getDefinitions() as $id => $definition) {
  25. if ($definition->isAbstract()) {
  26. $container->removeDefinition($id);
  27. $compiler->addLogMessage($formatter->formatRemoveService($this, $id, 'abstract'));
  28. }
  29. }
  30. }
  31. }