function ListingEmpty::render

Same name in this branch
  1. 11.x core/modules/block_content/src/Plugin/views/area/ListingEmpty.php \Drupal\block_content\Plugin\views\area\ListingEmpty::render()
Same name in other branches
  1. 9 core/modules/node/src/Plugin/views/area/ListingEmpty.php \Drupal\node\Plugin\views\area\ListingEmpty::render()
  2. 9 core/modules/block_content/src/Plugin/views/area/ListingEmpty.php \Drupal\block_content\Plugin\views\area\ListingEmpty::render()
  3. 8.9.x core/modules/node/src/Plugin/views/area/ListingEmpty.php \Drupal\node\Plugin\views\area\ListingEmpty::render()
  4. 8.9.x core/modules/block_content/src/Plugin/views/area/ListingEmpty.php \Drupal\block_content\Plugin\views\area\ListingEmpty::render()
  5. 10 core/modules/node/src/Plugin/views/area/ListingEmpty.php \Drupal\node\Plugin\views\area\ListingEmpty::render()
  6. 10 core/modules/block_content/src/Plugin/views/area/ListingEmpty.php \Drupal\block_content\Plugin\views\area\ListingEmpty::render()

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 [];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.