@@ 16-32 (lines=17) @@ | ||
13 | */ |
|
14 | class ControllerExtension extends Extension |
|
15 | { |
|
16 | public function onBeforeInit() |
|
17 | { |
|
18 | DebugBar::withDebugBar(function (\DebugBar\DebugBar $debugbar) { |
|
19 | // We must set the current controller when it's available and before it's pushed out of stack |
|
20 | $debugbar->getCollector('silverstripe')->setController(Controller::curr()); |
|
21 | ||
22 | /** @var $timeData DebugBar\DataCollector\TimeDataCollector */ |
|
23 | $timeData = $debugbar->getCollector('time'); |
|
24 | if (!$timeData) { |
|
25 | return; |
|
26 | } |
|
27 | if ($timeData->hasStartedMeasure('pre_request')) { |
|
28 | $timeData->stopMeasure("pre_request"); |
|
29 | } |
|
30 | $timeData->startMeasure("init", get_class($this->owner) . ' init'); |
|
31 | }); |
|
32 | } |
|
33 | ||
34 | public function onAfterInit() |
|
35 | { |
|
@@ 42-55 (lines=14) @@ | ||
39 | DebugBar::includeRequirements(); |
|
40 | } |
|
41 | ||
42 | DebugBar::withDebugBar(function (\DebugBar\DebugBar $debugbar) { |
|
43 | /** @var $timeData DebugBar\DataCollector\TimeDataCollector */ |
|
44 | $timeData = $debugbar->getCollector('time'); |
|
45 | if (!$timeData) { |
|
46 | return; |
|
47 | } |
|
48 | if ($timeData->hasStartedMeasure("cms_init")) { |
|
49 | $timeData->stopMeasure("cms_init"); |
|
50 | } |
|
51 | if ($timeData->hasStartedMeasure("init")) { |
|
52 | $timeData->stopMeasure("init"); |
|
53 | } |
|
54 | $timeData->startMeasure("handle", get_class($this->owner) . ' handle request'); |
|
55 | }); |
|
56 | } |
|
57 | ||
58 | /** |
|
@@ 106-124 (lines=19) @@ | ||
103 | * @param string $action |
|
104 | * @param mixed $result (only in v4.0) |
|
105 | */ |
|
106 | public function afterCallActionHandler($request, $action, $result) |
|
107 | { |
|
108 | self::clearBuffer(); |
|
109 | ||
110 | DebugBar::withDebugBar(function (\DebugBar\DebugBar $debugBar) use ($action) { |
|
111 | /** @var $timeData DebugBar\DataCollector\TimeDataCollector */ |
|
112 | $timeData = $debugBar->getCollector('time'); |
|
113 | if (!$timeData) { |
|
114 | return; |
|
115 | } |
|
116 | if ($timeData->hasStartedMeasure("action")) { |
|
117 | $timeData->stopMeasure("action"); |
|
118 | } |
|
119 | $timeData->startMeasure( |
|
120 | "after_action", |
|
121 | get_class($this->owner) . " after action $action" |
|
122 | ); |
|
123 | }); |
|
124 | } |
|
125 | ||
126 | protected static function clearBuffer() |
|
127 | { |