MonologCompilerPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 4
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 17 3
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher Updater Bundle.
5
 *
6
 * Copyright 2015 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú.
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\UpdaterBundle\DependencyInjection\Compiler;
16
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
19
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
20
use Symfony\Component\DependencyInjection\Reference;
21
22
/**
23
 * This pass enables separate Monolog channel for the bundle.
24
 */
25
class MonologCompilerPass implements CompilerPassInterface
26
{
27
    public function process(ContainerBuilder $container)
28
    {
29
        if (!$container->hasParameter('swp_updater.monolog_channel')) {
30
            return;
31
        }
32
33
        $bundles = $container->getParameter('kernel.bundles');
34
35
        if (!array_key_exists('MonologBundle', $bundles)) {
36
            throw new RuntimeException(
37
                'You have enabled the "monolog_channel" option but the MonologBundle is not registered'
38
            );
39
        }
40
41
        $loaderDef = $container->getDefinition('swp_updater.manager');
42
        $loaderDef->addArgument(new Reference('monolog.logger.updater'));
43
    }
44
}
45