| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* This file is part of the Symfony package.
|
|
|
5 |
*
|
|
|
6 |
* (c) Fabien Potencier <fabien@symfony.com>
|
|
|
7 |
*
|
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
|
|
9 |
* file that was distributed with this source code.
|
|
|
10 |
*/
|
|
|
11 |
|
|
|
12 |
namespace Symfony\Component\HttpKernel\DependencyInjection;
|
|
|
13 |
|
|
|
14 |
use Psr\Log\LoggerInterface;
|
|
|
15 |
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
|
|
16 |
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
|
17 |
use Symfony\Component\DependencyInjection\Reference;
|
|
|
18 |
use Symfony\Component\HttpFoundation\RequestStack;
|
|
|
19 |
use Symfony\Component\HttpKernel\Log\Logger;
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
* Registers the default logger if necessary.
|
|
|
23 |
*
|
|
|
24 |
* @author Kévin Dunglas <dunglas@gmail.com>
|
|
|
25 |
*/
|
|
|
26 |
class LoggerPass implements CompilerPassInterface
|
|
|
27 |
{
|
|
|
28 |
public function process(ContainerBuilder $container)
|
|
|
29 |
{
|
|
|
30 |
$container->setAlias(LoggerInterface::class, 'logger')
|
|
|
31 |
->setPublic(false);
|
|
|
32 |
|
|
|
33 |
if ($container->has('logger')) {
|
|
|
34 |
return;
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
$container->register('logger', Logger::class)
|
|
|
38 |
->setArguments([null, null, null, new Reference(RequestStack::class)])
|
|
|
39 |
->setPublic(false);
|
|
|
40 |
}
|
|
|
41 |
}
|