Completed
Push — master ( 89c9f0...9aceec )
by Thomas Mauro
06:33
created

Module::getConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
ccs 0
cts 2
cp 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Facile\SentryModule;
4
5
use Facile\SentryModule\Service\Client;
6
use Facile\SentryModule\Service\ErrorHandlerRegister;
7
use Zend\EventManager\EventInterface;
8
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
9
use Zend\ModuleManager\Feature\ConfigProviderInterface;
10
use Zend\Mvc\MvcEvent;
11
12
/**
13
 * Class Module
14
 */
15
class Module implements ConfigProviderInterface, BootstrapListenerInterface
16
{
17
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function getConfig()
22
    {
23
        return include __DIR__ . '/../config/module.config.php';
24
    }
25
26
    /**
27
     * Listen to the bootstrap event
28
     *
29
     * @param EventInterface $e
30
     * @return array
31
     * @throws \Interop\Container\Exception\NotFoundException
32
     * @throws \Interop\Container\Exception\ContainerException
33
     */
34
    public function onBootstrap(EventInterface $e)
35
    {
36
        /** @var MvcEvent $e */
37
        $application = $e->getApplication();
38
        $container = $application->getServiceManager();
39
        $moduleConfig = $container->get('config')['facile']['sentry'];
40
        $clients = array_keys($moduleConfig['client']);
41
42
        $errorHandlerRegister = $container->get(ErrorHandlerRegister::class);
43
        
44
        foreach ($clients as $serviceKey) {
45
            $serviceName = sprintf('facile.sentry.client.%s', $serviceKey);
46
            
47
            /** @var Client $raven */
48
            $client = $container->get($serviceName);
49
            $errorHandlerRegister->registerHandlers($client, $application->getEventManager());
50
        }
51
    }
52
}
53