| @@ 16-34 (lines=19) @@ | ||
| 13 | */ |
|
| 14 | class ControllerExtension extends Extension |
|
| 15 | { |
|
| 16 | public function onBeforeInit() |
|
| 17 | { |
|
| 18 | $class = get_class($this->owner); |
|
| 19 | ||
| 20 | DebugBar::withDebugBar(function (\DebugBar\DebugBar $debugbar) use ($class) { |
|
| 21 | // We must set the current controller when it's available and before it's pushed out of stack |
|
| 22 | $debugbar->getCollector('silverstripe')->setController(Controller::curr()); |
|
| 23 | ||
| 24 | /** @var $timeData DebugBar\DataCollector\TimeDataCollector */ |
|
| 25 | $timeData = $debugbar['time']; |
|
| 26 | if (!$timeData) { |
|
| 27 | return; |
|
| 28 | } |
|
| 29 | if ($timeData->hasStartedMeasure('pre_request')) { |
|
| 30 | $timeData->stopMeasure("pre_request"); |
|
| 31 | } |
|
| 32 | $timeData->startMeasure("init", "$class init"); |
|
| 33 | }); |
|
| 34 | } |
|
| 35 | ||
| 36 | public function onAfterInit() |
|
| 37 | { |
|
| @@ 113-132 (lines=20) @@ | ||
| 110 | * @param string $action |
|
| 111 | * @param mixed $result (only in v4.0) |
|
| 112 | */ |
|
| 113 | public function afterCallActionHandler($request, $action, $result) |
|
| 114 | { |
|
| 115 | self::clearBuffer(); |
|
| 116 | ||
| 117 | $class = get_class($this->owner); |
|
| 118 | DebugBar::withDebugBar(function (\DebugBar\DebugBar $debugbar) use ($class, $action) { |
|
| 119 | /* @var $timeData DebugBar\DataCollector\TimeDataCollector */ |
|
| 120 | $timeData = $debugbar['time']; |
|
| 121 | if (!$timeData) { |
|
| 122 | return; |
|
| 123 | } |
|
| 124 | if ($timeData->hasStartedMeasure("action")) { |
|
| 125 | $timeData->stopMeasure("action"); |
|
| 126 | } |
|
| 127 | $timeData->startMeasure( |
|
| 128 | "after_action", |
|
| 129 | "$class after action $action" |
|
| 130 | ); |
|
| 131 | }); |
|
| 132 | } |
|
| 133 | ||
| 134 | protected static function clearBuffer() |
|
| 135 | { |
|