You are here

public function CalendarHeader::render in Calendar 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/area/CalendarHeader.php \Drupal\calendar\Plugin\views\area\CalendarHeader::render()

Render the area.

Parameters

bool $empty: (optional) Indicator if view result is empty or not. Defaults to FALSE.

Return value

array In any case we need a valid Drupal render array to return.

Overrides AreaPluginBase::render

File

src/Plugin/views/area/CalendarHeader.php, line 54

Class

CalendarHeader
Views area Calendar Header area.

Namespace

Drupal\calendar\Plugin\views\area

Code

public function render($empty = FALSE) {
  if (!$empty || !empty($this->options['empty'])) {
    $argument = CalendarHelper::getDateArgumentHandler($this->view);
    $render = [];
    $header_text = $this
      ->renderTextField($this->options['content']);
    if (!$this->options['pager_embed']) {
      $render = [
        '#theme' => 'calendar_header',
        '#title' => $header_text,
        '#empty' => $empty,
        '#granularity' => $argument
          ->getGranularity(),
      ];
    }
    else {
      if ($this->view->display_handler
        ->renderPager()) {
        $exposed_input = isset($this->view->exposed_raw_input) ? $this->view->exposed_raw_input : NULL;
        $render = $this->view
          ->renderPager($exposed_input);

        // Override the exclude option of the pager.
        if (is_array($render)) {
          $render['#exclude'] = FALSE;
          $render['#items']['current'] = $header_text;
        }
      }
    }
    return $render;
  }
  return [];
}