1 | <?php |
||
18 | class Dev extends Module |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * Library class instance |
||
23 | * @var \gplcart\core\Library |
||
24 | */ |
||
25 | protected $library; |
||
26 | |||
27 | /** |
||
28 | * @param Library $library |
||
29 | */ |
||
30 | public function __construct(Library $library) |
||
36 | |||
37 | /** |
||
38 | * Implements hook "construct" |
||
39 | */ |
||
40 | public function hookConstruct() |
||
44 | |||
45 | /** |
||
46 | * Implements hook "construct.controller" |
||
47 | * @param \gplcart\core\Controller $object |
||
48 | */ |
||
49 | public function hookConstructController($object) |
||
56 | |||
57 | /** |
||
58 | * Implements hook "destruct.controller" |
||
59 | * @param \gplcart\core\Controller $controller |
||
60 | */ |
||
61 | public function hookDestructController($controller) |
||
62 | { |
||
63 | $disabled = $controller->isPosted() || $controller->isAjax(); |
||
64 | |||
65 | if (!$disabled && $this->config->module('dev', 'status')) { |
||
66 | $this->outputToolbar($controller); |
||
67 | } |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Render and print dev toolbar |
||
72 | * @param \gplcart\core\Controller $controller |
||
73 | */ |
||
74 | protected function outputToolbar($controller) |
||
75 | { |
||
76 | /* @var $db \gplcart\core\Database */ |
||
77 | $db = $this->config->getDb(); |
||
78 | |||
79 | $data = array( |
||
80 | 'queries' => $db->getLogs(), |
||
81 | 'time' => microtime(true) - GC_START, |
||
82 | 'key' => $this->config->module('dev', 'key') |
||
83 | ); |
||
84 | |||
85 | echo $controller->render('dev|toolbar', $data); |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Implements hook "library.list" |
||
90 | * @param array $libraries |
||
91 | */ |
||
92 | public function hookLibraryList(array &$libraries) |
||
107 | |||
108 | /** |
||
109 | * Implements hook "route.list" |
||
110 | * @param array $routes |
||
111 | */ |
||
112 | public function hookRouteList(array &$routes) |
||
121 | |||
122 | /** |
||
123 | * Implements hook "module.enable.after" |
||
124 | */ |
||
125 | public function hookModuleEnableAfter() |
||
129 | |||
130 | /** |
||
131 | * Implements hook "module.disable.after" |
||
132 | */ |
||
133 | public function hookModuleDisableAfter() |
||
137 | |||
138 | /** |
||
139 | * Implements hook "module.install.after" |
||
140 | */ |
||
141 | public function hookModuleInstallAfter() |
||
145 | |||
146 | /** |
||
147 | * Implements hook "module.uninstall.after" |
||
148 | */ |
||
149 | public function hookModuleUninstallAfter() |
||
153 | |||
154 | } |
||
155 |