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

Module   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 0
cbo 2
dl 0
loc 38
rs 10
ccs 0
cts 4
cp 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfig() 0 4 1
A onBootstrap() 0 18 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