twig = $twig; } // Register the Twig profiler extension public function listenToEvents() { $this->twig->addExtension(new Twig_Extension_Profiler($this->profile = new Twig_Profiler_Profile)); } // Adds rendered views to the request public function resolve(Request $request) { $timeline = (new ProfilerClockworkDumper)->dump($this->profile); $request->viewsData = array_merge($request->viewsData, $timeline->finalize()); return $request; } }