SumoCodersFrameworkErrorExtension::loadInternal()   B
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 36
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 36
ccs 18
cts 18
cp 1
rs 8.439
c 0
b 0
f 0
cc 5
eloc 22
nc 4
nop 2
crap 5
1
<?php
2
3
namespace SumoCoders\FrameworkErrorBundle\DependencyInjection;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;
7
use Symfony\Component\DependencyInjection\Definition;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
class SumoCodersFrameworkErrorExtension extends ConfigurableExtension
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 2
    protected function loadInternal(array $mergedConfig, ContainerBuilder $container)
16
    {
17 2
        $showMessagesFor = array();
18
19 2
        if (isset($mergedConfig['show_messages_for'])) {
20 2
            $showMessagesFor = array_unique($mergedConfig['show_messages_for']);
21
        }
22
23
        // store the configuration in the messages
24 2
        $container->setParameter(
25 2
            'sumo_coders_framework_error.show_messages_for',
26
            $showMessagesFor
27
        );
28
29
        if (
30 2
            $container->hasParameter('errbit_api_key')
31 2
            && $container->getParameter('errbit_api_key') !== null
32 2
            && $container->getParameter('errbit_api_key') !== ''
33
        ) {
34 1
            $definition = new Definition(
35 1
                'SumoCoders\FrameworkErrorBundle\Listener\ConsoleExceptionListener',
36 1
                array(new Reference('eo_airbrake.client'))
37
            );
38 1
            $definition->addTag(
39 1
                'kernel.event_listener',
40
                array(
41 1
                    'event' => 'console.exception',
42
                    'method' => 'onConsoleException',
43
                )
44
            );
45 1
            $container->setDefinition(
46 1
                'sumocoders_console_error_handler',
47
                $definition
48
            );
49
        }
50 2
    }
51
}
52