ZendLoggerWriterPass.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Symfony\Bundle\ZendBundle\DependencyInjection\Compiler;
  3. use Symfony\Component\DependencyInjection\Reference;
  4. use Symfony\Component\DependencyInjection\ContainerBuilder;
  5. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  6. /*
  7. * This file is part of the Symfony package.
  8. *
  9. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  10. *
  11. * For the full copyright and license information, please view the LICENSE
  12. * file that was distributed with this source code.
  13. */
  14. /**
  15. * Adds tagged zend.logger.writer services to zend.logger service
  16. *
  17. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  18. */
  19. class ZendLoggerWriterPass implements CompilerPassInterface
  20. {
  21. public function process(ContainerBuilder $container)
  22. {
  23. if (false === $container->hasDefinition('zend.logger')) {
  24. return;
  25. }
  26. $definition = $container->getDefinition('zend.logger');
  27. foreach ($container->findTaggedServiceIds('zend.logger.writer') as $id => $attributes) {
  28. $definition->addMethodCall('addWriter', array(new Reference($id)));
  29. }
  30. }
  31. }