public function listenToEvents()
{
$this->timeline->startEvent('total', 'Total execution time.', 'start');
$this->timeline->startEvent('initialisation', 'Application initialisation.', 'start');
$this->app->booting(function () {
$this->timeline->endEvent('initialisation');
$this->timeline->startEvent('boot', 'Framework booting.');
$this->timeline->startEvent('run', 'Framework running.');
});
$this->app->booted(function () {
$this->timeline->endEvent('boot');
});
$this->app['events']->listen('clockwork.controller.start', function () use($timeline) {
$this->timeline->startEvent('controller', 'Controller running.');
});
$this->app['events']->listen('clockwork.controller.end', function () {
$this->timeline->endEvent('controller');
});
$this->app['events']->listen('illuminate.log', function ($level, $message, $context) {
$this->log->log($level, $message, $context);
});
$this->app['events']->listen('composing:*', function ($view) {
$time = microtime(true);
$this->views->addEvent('view ' . $view->getName(), 'Rendering a view', $time, $time, ['name' => $view->getName(), 'data' => $this->replaceUnserializable($view->getData())]);
});
}