You are here

public function ListingEmpty::render in Drupal 8

Same name in this branch
  1. 8 core/modules/node/src/Plugin/views/area/ListingEmpty.php \Drupal\node\Plugin\views\area\ListingEmpty::render()
  2. 8 core/modules/block_content/src/Plugin/views/area/ListingEmpty.php \Drupal\block_content\Plugin\views\area\ListingEmpty::render()
Same name and namespace in other branches
  1. 9 core/modules/node/src/Plugin/views/area/ListingEmpty.php \Drupal\node\Plugin\views\area\ListingEmpty::render()
  2. 10 core/modules/node/src/Plugin/views/area/ListingEmpty.php \Drupal\node\Plugin\views\area\ListingEmpty::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

core/modules/node/src/Plugin/views/area/ListingEmpty.php, line 59

Class

ListingEmpty
Defines an area plugin to display a node/add link.

Namespace

Drupal\node\Plugin\views\area

Code

public function render($empty = FALSE) {
  $account = \Drupal::currentUser();
  if (!$empty || !empty($this->options['empty'])) {
    $element = [
      '#theme' => 'links',
      '#links' => [
        [
          'url' => Url::fromRoute('node.add_page'),
          'title' => $this
            ->t('Add content'),
        ],
      ],
      '#access' => $this->accessManager
        ->checkNamedRoute('node.add_page', [], $account),
    ];
    return $element;
  }
  return [];
}