TraceableViewExecutable.php in Devel 4.x
File
webprofiler/src/Views/TraceableViewExecutable.php
View source
<?php
namespace Drupal\webprofiler\Views;
use Drupal\views\ViewExecutable;
use Drupal\views\Views;
use Symfony\Component\HttpFoundation\Response;
class TraceableViewExecutable extends ViewExecutable {
protected $render_time;
public function getBuildTime() {
return $this->build_time;
}
public function getExecuteTime() {
return property_exists($this, 'execute_time') ? $this->execute_time : 0.0;
}
public function getRenderTime() {
return $this->render_time;
}
public function render($display_id = NULL) {
$start = microtime(TRUE);
$this
->execute($display_id);
if (!empty($this->build_info['fail'])) {
return;
}
if (!empty($this->build_info['denied'])) {
return;
}
$exposed_form = $this->display_handler
->getPlugin('exposed_form');
$exposed_form
->preRender($this->result);
$module_handler = \Drupal::moduleHandler();
$active_theme = \Drupal::theme()
->getActiveTheme();
$themes = array_keys($active_theme
->getBaseThemeExtensions());
$themes[] = $active_theme
->getName();
if (!empty($this->live_preview)) {
$cache = Views::pluginManager('cache')
->createInstance('none');
}
else {
$cache = $this->display_handler
->getPlugin('cache');
}
if (!empty($this->pager)) {
$this->pager
->preRender($this->result);
}
$this
->initStyle();
if (!isset($this->response)) {
$this->response = new Response('', 200);
}
if ($this->style_plugin
->usesFields()) {
foreach ($this->field as $id => $handler) {
if (!empty($this->field[$id])) {
$this->field[$id]
->preRender($this->result);
}
}
}
$this->style_plugin
->preRender($this->result);
$areas = [
'header',
'footer',
];
if (empty($this->result)) {
$areas[] = 'empty';
}
foreach ($areas as $area) {
foreach ($this->{$area} as $handler) {
$handler
->preRender($this->result);
}
}
$module_handler
->invokeAll('views_pre_render', [
$this,
]);
foreach ($themes as $theme_name) {
$function = $theme_name . '_views_pre_render';
if (function_exists($function)) {
$function($this);
}
}
$this->display_handler->output = $this->display_handler
->render();
$exposed_form
->postRender($this->display_handler->output);
$cache
->postRender($this->display_handler->output);
$module_handler
->invokeAll('views_post_render', [
$this,
&$this->display_handler->output,
$cache,
]);
foreach ($themes as $theme_name) {
$function = $theme_name . '_views_post_render';
if (function_exists($function)) {
$function($this, $this->display_handler->output, $cache);
}
}
$this->render_time = microtime(TRUE) - $start;
return $this->display_handler->output;
}
}