function ViewsDataCollector::collect
File
-
webprofiler/
src/ DataCollector/ ViewsDataCollector.php, line 45
Class
- ViewsDataCollector
- Collects data about rendered views.
Namespace
Drupal\webprofiler\DataCollectorCode
public function collect(Request $request, Response $response, \Exception $exception = NULL) {
$views = $this->view_executable_factory
->getViews();
$storage = $this->entityManager
->getStorage('view');
/** @var TraceableViewExecutable $view */
foreach ($views as $view) {
if ($view->executed) {
$data = [
'id' => $view->storage
->id(),
'current_display' => $view->current_display,
'build_time' => $view->getBuildTime(),
'execute_time' => $view->getExecuteTime(),
'render_time' => $view->getRenderTime(),
];
$entity = $storage->load($view->storage
->id());
if ($entity->hasLinkTemplate('edit-display-form')) {
$route = $entity->toUrl('edit-display-form');
$route->setRouteParameter('display_id', $view->current_display);
$data['route'] = $route->toString();
}
$this->data['views'][] = $data;
}
}
// TODO: also use those data.
// $loaded = $this->entityManager->getLoaded('view');
//
// if ($loaded) {
// /** @var \Drupal\webprofiler\Entity\EntityStorageDecorator $views */
// foreach ($loaded->getEntities() as $views) {
// $this->data['views'][] = array(
// 'id' => $views->get('id'),
// );
// }
// }
}