class ListingEmpty in Drupal 10
Same name in this branch
- 10 core/modules/node/src/Plugin/views/area/ListingEmpty.php \Drupal\node\Plugin\views\area\ListingEmpty
- 10 core/modules/block_content/src/Plugin/views/area/ListingEmpty.php \Drupal\block_content\Plugin\views\area\ListingEmpty
Same name and namespace in other branches
- 8 core/modules/node/src/Plugin/views/area/ListingEmpty.php \Drupal\node\Plugin\views\area\ListingEmpty
- 9 core/modules/node/src/Plugin/views/area/ListingEmpty.php \Drupal\node\Plugin\views\area\ListingEmpty
Defines an area plugin to display a node/add link.
Plugin annotation
@ViewsArea("node_listing_empty");
Hierarchy
- class \Drupal\views\Plugin\views\area\AreaPluginBase extends \Drupal\views\Plugin\views\HandlerBase
- class \Drupal\node\Plugin\views\area\ListingEmpty
Expanded class hierarchy of ListingEmpty
Related topics
File
- core/
modules/ node/ src/ Plugin/ views/ area/ ListingEmpty.php, line 17
Namespace
Drupal\node\Plugin\views\areaView source
class ListingEmpty extends AreaPluginBase {
/**
* The access manager.
*
* @var \Drupal\Core\Access\AccessManagerInterface
*/
protected $accessManager;
/**
* Constructs a new ListingEmpty.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin ID for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Access\AccessManagerInterface $access_manager
* The access manager.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, AccessManagerInterface $access_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->accessManager = $access_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('access_manager'));
}
/**
* {@inheritdoc}
*/
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 [];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AreaPluginBase:: |
public | property | The type of this area handler, i.e. 'header', 'footer', or 'empty'. | |
AreaPluginBase:: |
public | function | ||
AreaPluginBase:: |
public | function | 6 | |
AreaPluginBase:: |
protected | function | 7 | |
AreaPluginBase:: |
public | function | Overrides Drupal\views\Plugin\views\HandlerBase::init(). | 1 |
AreaPluginBase:: |
public | function | Does that area have nothing to show. | 1 |
AreaPluginBase:: |
public | function | Performs any operations needed before full rendering. | 1 |
AreaPluginBase:: |
public | function | ||
ListingEmpty:: |
protected | property | The access manager. | |
ListingEmpty:: |
public static | function | ||
ListingEmpty:: |
public | function |
Render the area. Overrides AreaPluginBase:: |
|
ListingEmpty:: |
public | function | Constructs a new ListingEmpty. |