This repository has been archived by the owner on Jun 25, 2022. It is now read-only.
forked from insekticid/ZF2-Nette-Debug
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathModule.php
104 lines (86 loc) · 2.78 KB
/
Module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/**
* Webino (http://www.webino.org/)
*
* @copyright Copyright (c) 2012 Peter Bačinský (http://www.bacinsky.sk/)
* @license New BSD License
* @package ZF2NetteDebug
*/
namespace ZF2NetteDebug;
use Zend\Mvc\MvcEvent;
use Nette\Diagnostics\Debugger;
/**
* @category Webino
* @package Zf2NetteDebug
* @author Peter Bačinský <peter@bacinsky.sk>
*/
class Module
{
/**
* Setup Nette\Debugger with options
*
* @param MvcEvent $e
* @return void
*/
public function onBootstrap(MvcEvent $e)
{
$app = $e->getApplication();
$config = $app->getConfig();
if (empty($config['nette_debug'])
|| empty($config['nette_debug']['enabled'])
) return;
require __DIR__ . '/src/Nette/Diagnostics/exceptions.php';
array_key_exists('bar', $config['nette_debug']) or
$config['nette_debug']['bar'] = true;
array_key_exists('mode', $config['nette_debug']) or
$config['nette_debug']['mode'] = null;
array_key_exists('log', $config['nette_debug']) or
$config['nette_debug']['log'] = null;
array_key_exists('email', $config['nette_debug']) or
$config['nette_debug']['email'] = null;
Debugger::_init();
$config['nette_debug']['bar'] or Debugger::$bar = null;
Debugger::enable(
$config['nette_debug']['mode'],
$config['nette_debug']['log'],
$config['nette_debug']['email']
);
!array_key_exists('strict', $config['nette_debug']) or
Debugger::$strictMode = $config['nette_debug']['strict'];
!array_key_exists('max_depth', $config['nette_debug']) or
Debugger::$maxDepth = $config['nette_debug']['max_depth'];
!array_key_exists('max_len', $config['nette_debug']) or
Debugger::$maxLen = $config['nette_debug']['max_len'];
!array_key_exists('template_map', $config['nette_debug']) or
$app->getServiceManager()->get('viewtemplatemapresolver')->merge(
$config['nette_debug']['template_map']
);
}
/**
* Module default config
*
* @return array
*/
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
/**
* Default autoloader config
*
* @return array
*/
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
'Nette' => __DIR__ . '/src/Nette',
),
),
);
}
}