public function DisplayPluginBase::elementPreRender in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Plugin/views/display/DisplayPluginBase.php \Drupal\views\Plugin\views\display\DisplayPluginBase::elementPreRender()
#pre_render callback for view display rendering.
Parameters
array $element: The element to #pre_render
Return value
array The processed element.
Overrides DisplayPluginInterface::elementPreRender
See also
File
- core/
modules/ views/ src/ Plugin/ views/ display/ DisplayPluginBase.php, line 2159 - Contains \Drupal\views\Plugin\views\display\DisplayPluginBase.
Class
- DisplayPluginBase
- Base class for views display plugins.
Namespace
Drupal\views\Plugin\views\displayCode
public function elementPreRender(array $element) {
$view = $element['#view'];
$empty = empty($view->result);
// Force a render array so CSS/JS can be attached.
if (!is_array($element['#rows'])) {
$element['#rows'] = array(
'#markup' => $element['#rows'],
);
}
$element['#header'] = $view->display_handler
->renderArea('header', $empty);
$element['#footer'] = $view->display_handler
->renderArea('footer', $empty);
$element['#empty'] = $empty ? $view->display_handler
->renderArea('empty', $empty) : array();
$element['#exposed'] = !empty($view->exposed_widgets) ? $view->exposed_widgets : array();
$element['#more'] = $view->display_handler
->renderMoreLink();
$element['#feed_icons'] = !empty($view->feedIcons) ? $view->feedIcons : array();
if ($view->display_handler
->renderPager()) {
$exposed_input = isset($view->exposed_raw_input) ? $view->exposed_raw_input : NULL;
$element['#pager'] = $view
->renderPager($exposed_input);
}
if (!empty($view->attachment_before)) {
$element['#attachment_before'] = $view->attachment_before;
}
if (!empty($view->attachment_after)) {
$element['#attachment_after'] = $view->attachment_after;
}
// If form fields were found in the view, reformat the view output as a form.
if ($view
->hasFormElements()) {
// Only render row output if there are rows. Otherwise, render the empty
// region.
if (!empty($element['#rows'])) {
$output = $element['#rows'];
}
else {
$output = $element['#empty'];
}
$form_object = ViewsForm::create(\Drupal::getContainer(), $view->storage
->id(), $view->current_display);
$form = \Drupal::formBuilder()
->getForm($form_object, $view, $output);
// The form is requesting that all non-essential views elements be hidden,
// usually because the rendered step is not a view result.
if ($form['show_view_elements']['#value'] == FALSE) {
$element['#header'] = array();
$element['#exposed'] = array();
$element['#pager'] = array();
$element['#footer'] = array();
$element['#more'] = array();
$element['#feed_icons'] = array();
}
$element['#rows'] = $form;
}
return $element;
}