You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.0 KiB

3 years ago
  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\HttpKernel\DependencyInjection;
  11. use Psr\Log\LoggerInterface;
  12. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  13. use Symfony\Component\DependencyInjection\ContainerBuilder;
  14. use Symfony\Component\HttpKernel\Log\Logger;
  15. /**
  16. * Registers the default logger if necessary.
  17. *
  18. * @author Kévin Dunglas <dunglas@gmail.com>
  19. */
  20. class LoggerPass implements CompilerPassInterface
  21. {
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function process(ContainerBuilder $container)
  26. {
  27. $container->setAlias(LoggerInterface::class, 'logger')
  28. ->setPublic(false);
  29. if ($container->has('logger')) {
  30. return;
  31. }
  32. $container->register('logger', Logger::class)
  33. ->setPublic(false);
  34. }
  35. }