-
Notifications
You must be signed in to change notification settings - Fork 1
/
OnelogBundle.php
44 lines (38 loc) · 1.64 KB
/
OnelogBundle.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php declare(strict_types=1);
namespace KoderHut\OnelogBundle;
use KoderHut\OnelogBundle\DependencyInjection\Compiler\LoggerWrapPass;
use KoderHut\OnelogBundle\DependencyInjection\Compiler\RegisterMonologChannels;
use KoderHut\OnelogBundle\DependencyInjection\Compiler\RequestIdentifierPass;
use KoderHut\OnelogBundle\Helper\GlobalNamespaceRegister;
use KoderHut\OnelogBundle\Helper\OneLogStatic;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
/**
* Class KoderHut\OnelogBundle
*
* @author Denis-Florin Rendler <[email protected]>
*/
class OnelogBundle extends Bundle
{
public function boot()
{
if (true === $this->container->getParameter('onelog.register_global')) {
$onelogService = $this->container->get(OneLog::class);
OneLogStatic::setInstance($onelogService);
GlobalNamespaceRegister::register('\\OneLog', OneLogStatic::class);
}
if (!empty($middlewares = $this->container->getParameter('onelog.middlewares'))) {
$middlewareProcessor = $this->container->get(MiddlewareProcessor::class);
foreach ($middlewares as $middleware) {
$middlewareProcessor->registerMiddleware($this->container->get($middleware));
}
$this->container->get(OneLog::class)->setMiddlewareProcessor($middlewareProcessor);
}
}
public function build(ContainerBuilder $container)
{
$container->addCompilerPass(new LoggerWrapPass());
$container->addCompilerPass(new RegisterMonologChannels());
$container->addCompilerPass(new RequestIdentifierPass());
}
}