public function ViewsDataCollector::collect in Devel 8.3
Same name and namespace in other branches
- 8 webprofiler/src/DataCollector/ViewsDataCollector.php \Drupal\webprofiler\DataCollector\ViewsDataCollector::collect()
- 8.2 webprofiler/src/DataCollector/ViewsDataCollector.php \Drupal\webprofiler\DataCollector\ViewsDataCollector::collect()
- 4.x webprofiler/src/DataCollector/ViewsDataCollector.php \Drupal\webprofiler\DataCollector\ViewsDataCollector::collect()
File
- webprofiler/
src/ DataCollector/ ViewsDataCollector.php, line 44
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->entityTypeManager
->getStorage('view');
/** @var \Drupal\webprofiler\Views\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->entityTypeManager->getLoaded('view');
//
// if ($loaded) {
// /** @var \Drupal\webprofiler\Entity\EntityStorageDecorator $views */
// foreach ($loaded->getEntities() as $views) {
// $this->data['views'][] = array(
// 'id' => $views->get('id'),
// );
// }
// }.
}