You are here

public function EntityBrowser::elementPreRender in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/display/EntityBrowser.php \Drupal\entity_browser\Plugin\views\display\EntityBrowser::elementPreRender()

Pre render callback for a view.

Based on DisplayPluginBase::elementPreRender() except that we removed form part which need to handle by our own.

Overrides DisplayPluginBase::elementPreRender

File

src/Plugin/views/display/EntityBrowser.php, line 115

Class

EntityBrowser
The plugin that handles entity browser display.

Namespace

Drupal\entity_browser\Plugin\views\display

Code

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'] = [
      '#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) : [];
  $element['#exposed'] = !empty($view->exposed_widgets) ? $view->exposed_widgets : [];
  $element['#more'] = $view->display_handler
    ->renderMoreLink();
  $element['#feed_icons'] = !empty($view->feedIcons) ? $view->feedIcons : [];
  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;
  }
  return $element;
}