1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Facile\SentryModule; |
4
|
|
|
|
5
|
|
|
use Facile\SentryModule\Options\ConfigurationInterface; |
6
|
|
|
use Zend\EventManager\EventInterface; |
7
|
|
|
use Zend\ModuleManager\Feature\BootstrapListenerInterface; |
8
|
|
|
use Zend\ModuleManager\Feature\ConfigProviderInterface; |
9
|
|
|
use Zend\Mvc\MvcEvent; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class Module. |
13
|
|
|
*/ |
14
|
|
|
class Module implements ConfigProviderInterface, BootstrapListenerInterface |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* {@inheritdoc} |
18
|
|
|
*/ |
19
|
|
|
public function getConfig() |
20
|
|
|
{ |
21
|
|
|
return include __DIR__.'/../config/module.config.php'; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Listen to the bootstrap event. |
26
|
|
|
* |
27
|
|
|
* @param EventInterface $e |
28
|
|
|
* |
29
|
|
|
* @return void |
30
|
|
|
* |
31
|
|
|
* @throws \Zend\ServiceManager\Exception\ServiceNotFoundException |
32
|
|
|
* @throws \Zend\ServiceManager\Exception\InvalidServiceException |
33
|
|
|
* @throws \RuntimeException |
34
|
|
|
* @throws \Interop\Container\Exception\NotFoundException |
35
|
|
|
* @throws \Interop\Container\Exception\ContainerException |
36
|
|
|
*/ |
37
|
3 |
|
public function onBootstrap(EventInterface $e) |
38
|
|
|
{ |
39
|
|
|
/* @var MvcEvent $e */ |
40
|
3 |
|
$application = $e->getApplication(); |
41
|
3 |
|
$container = $application->getServiceManager(); |
42
|
|
|
|
43
|
|
|
/** @var ConfigurationInterface $configuration */ |
44
|
3 |
|
$configuration = $container->get(ConfigurationInterface::class); |
45
|
|
|
|
46
|
3 |
|
if ($configuration->shouldInjectRavenJavascript()) { |
47
|
|
|
/** @var \Zend\View\HelperPluginManager $viewHelperManager */ |
48
|
2 |
|
$viewHelperManager = $container->get('ViewHelperManager'); |
49
|
|
|
/** @var \Zend\View\Helper\HeadScript $headScriptHelper */ |
50
|
2 |
|
$headScriptHelper = $viewHelperManager->get('HeadScript'); |
51
|
2 |
|
$jsScript = $configuration->getRavenJavascriptUri(); |
52
|
2 |
|
if (! empty($jsScript)) { |
53
|
1 |
|
$headScriptHelper->appendFile($jsScript); |
54
|
|
|
} |
55
|
2 |
|
$headScriptHelper->appendScript( |
56
|
2 |
|
sprintf( |
57
|
2 |
|
'Raven.config(\'%s\', %s).install();', |
58
|
2 |
|
$configuration->getRavenJavascriptDsn(), |
59
|
2 |
|
json_encode($configuration->getRavenJavascriptOptions()) |
60
|
|
|
) |
61
|
|
|
); |
62
|
|
|
} |
63
|
3 |
|
} |
64
|
|
|
} |
65
|
|
|
|