RemoveAbstractDefinitionsPass.php 1.0 KB

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