ListingEmpty.php in Zircon Profile 8
File
core/modules/node/src/Plugin/views/area/ListingEmpty.php
View source
<?php
namespace Drupal\node\Plugin\views\area;
use Drupal\Core\Access\AccessManagerInterface;
use Drupal\Core\Url;
use Drupal\views\Plugin\views\area\AreaPluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ListingEmpty extends AreaPluginBase {
protected $accessManager;
public function __construct(array $configuration, $plugin_id, $plugin_definition, AccessManagerInterface $access_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->accessManager = $access_manager;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('access_manager'));
}
public function render($empty = FALSE) {
$account = \Drupal::currentUser();
if (!$empty || !empty($this->options['empty'])) {
$element = array(
'#theme' => 'links',
'#links' => array(
array(
'url' => Url::fromRoute('node.add_page'),
'title' => $this
->t('Add content'),
),
),
'#access' => $this->accessManager
->checkNamedRoute('node.add_page', array(), $account),
);
return $element;
}
return array();
}
}
Classes
Name |
Description |
ListingEmpty |
Defines an area plugin to display a node/add link. |