|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Facile\SentryModule; |
|
4
|
|
|
|
|
5
|
|
|
use Facile\SentryModule\Options\ConfigurationOptions; |
|
6
|
|
|
use Facile\SentryModule\Service\Client; |
|
7
|
|
|
use Facile\SentryModule\Service\ErrorHandlerRegister; |
|
8
|
|
|
use Zend\EventManager\EventInterface; |
|
9
|
|
|
use Zend\ModuleManager\Feature\BootstrapListenerInterface; |
|
10
|
|
|
use Zend\ModuleManager\Feature\ConfigProviderInterface; |
|
11
|
|
|
use Zend\Mvc\MvcEvent; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class Module. |
|
15
|
|
|
*/ |
|
16
|
|
|
class Module implements ConfigProviderInterface, BootstrapListenerInterface |
|
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
|
|
|
* |
|
31
|
|
|
* @return array |
|
32
|
|
|
* |
|
33
|
|
|
* @throws \Zend\ServiceManager\Exception\ServiceNotFoundException |
|
34
|
|
|
* @throws \Zend\ServiceManager\Exception\InvalidServiceException |
|
35
|
|
|
* @throws \RuntimeException |
|
36
|
|
|
* @throws \Interop\Container\Exception\NotFoundException |
|
37
|
|
|
* @throws \Interop\Container\Exception\ContainerException |
|
38
|
|
|
*/ |
|
39
|
|
|
public function onBootstrap(EventInterface $e) |
|
40
|
|
|
{ |
|
41
|
|
|
/* @var MvcEvent $e */ |
|
42
|
|
|
$application = $e->getApplication(); |
|
43
|
|
|
$container = $application->getServiceManager(); |
|
44
|
|
|
$moduleConfig = $container->get('config')['facile']['sentry']; |
|
45
|
|
|
$clients = array_keys($moduleConfig['client']); |
|
46
|
|
|
|
|
47
|
|
|
$errorHandlerRegister = $container->get(ErrorHandlerRegister::class); |
|
48
|
|
|
|
|
49
|
|
|
foreach ($clients as $serviceKey) { |
|
50
|
|
|
$serviceName = sprintf('facile.sentry.client.%s', $serviceKey); |
|
51
|
|
|
|
|
52
|
|
|
/* @var Client $client */ |
|
53
|
|
|
$client = $container->get($serviceName); |
|
54
|
|
|
$errorHandlerRegister->registerHandlers($client, $application->getEventManager()); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
$configurationOptions = $container->get(ConfigurationOptions::class); |
|
58
|
|
|
if (!$configurationOptions->isInjectRavenJavascript()) { |
|
59
|
|
|
return; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** @var \Zend\View\HelperPluginManager $viewHelperManager */ |
|
63
|
|
|
$viewHelperManager = $container->get('ViewHelperManager'); |
|
64
|
|
|
/** @var \Zend\View\Helper\HeadScript $headScriptHelper */ |
|
65
|
|
|
$headScriptHelper = $viewHelperManager->get('HeadScript'); |
|
66
|
|
|
$headScriptHelper->appendFile($configurationOptions->getRavenJavascriptUri()); |
|
67
|
|
|
$headScriptHelper->appendScript( |
|
68
|
|
|
sprintf('Raven.config(\'%s\').install()', $configurationOptions->getRavenJavascriptDsn()) |
|
69
|
|
|
); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|