RemoveAbstractDefinitionsPass.php 908 B

123456789101112131415161718192021222324252627282930313233
  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. foreach ($container->getDefinitions() as $id => $definition) {
  23. if ($definition->isAbstract()) {
  24. $container->removeDefinition($id);
  25. $container->log($this, sprintf('Removed service "%s"; reason: abstract.', $id));
  26. }
  27. }
  28. }
  29. }