class ViewsMenuLink
Same name in this branch
- 10 core/modules/views/src/Plugin/Menu/ViewsMenuLink.php \Drupal\views\Plugin\Menu\ViewsMenuLink
Same name in other branches
- 9 core/modules/views/src/Plugin/Menu/ViewsMenuLink.php \Drupal\views\Plugin\Menu\ViewsMenuLink
- 9 core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php \Drupal\views\Plugin\Derivative\ViewsMenuLink
- 8.9.x core/modules/views/src/Plugin/Menu/ViewsMenuLink.php \Drupal\views\Plugin\Menu\ViewsMenuLink
- 8.9.x core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php \Drupal\views\Plugin\Derivative\ViewsMenuLink
- 11.x core/modules/views/src/Plugin/Menu/ViewsMenuLink.php \Drupal\views\Plugin\Menu\ViewsMenuLink
- 11.x core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php \Drupal\views\Plugin\Derivative\ViewsMenuLink
Provides menu links for Views.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements \Drupal\Component\Plugin\Derivative\DeriverInterface
- class \Drupal\views\Plugin\Derivative\ViewsMenuLink extends \Drupal\Component\Plugin\Derivative\DeriverBase implements \Drupal\Core\Plugin\Discovery\ContainerDeriverInterface
Expanded class hierarchy of ViewsMenuLink
See also
\Drupal\views\Plugin\Menu\ViewsMenuLink
1 string reference to 'ViewsMenuLink'
- views.links.menu.yml in core/
modules/ views/ views.links.menu.yml - core/modules/views/views.links.menu.yml
File
-
core/
modules/ views/ src/ Plugin/ Derivative/ ViewsMenuLink.php, line 17
Namespace
Drupal\views\Plugin\DerivativeView source
class ViewsMenuLink extends DeriverBase implements ContainerDeriverInterface {
/**
* The view storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $viewStorage;
/**
* Constructs a \Drupal\views\Plugin\Derivative\ViewsLocalTask instance.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $view_storage
* The view storage.
*/
public function __construct(EntityStorageInterface $view_storage) {
$this->viewStorage = $view_storage;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container->get('entity_type.manager')
->getStorage('view'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$links = [];
$views = Views::getApplicableViews('uses_menu_links');
foreach ($views as $data) {
[
$view_id,
$display_id,
] = $data;
/** @var \Drupal\views\ViewExecutable $executable */
$executable = $this->viewStorage
->load($view_id)
->getExecutable();
$executable->initDisplay();
$display = $executable->displayHandlers
->get($display_id);
if ($display instanceof DisplayMenuInterface && ($result = $display->getMenuLinks())) {
foreach ($result as $link_id => $link) {
$links[$link_id] = $link + $base_plugin_definition;
}
}
}
return $links;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
DeriverBase::$derivatives | protected | property | List of derivative definitions. | 1 | |
DeriverBase::getDerivativeDefinition | public | function | Gets the definition of a derivative plugin. | Overrides DeriverInterface::getDerivativeDefinition | |
ViewsMenuLink::$viewStorage | protected | property | The view storage. | ||
ViewsMenuLink::create | public static | function | Creates a new class instance. | Overrides ContainerDeriverInterface::create | |
ViewsMenuLink::getDerivativeDefinitions | public | function | Gets the definition of all derivatives of a base plugin. | Overrides DeriverBase::getDerivativeDefinitions | |
ViewsMenuLink::__construct | public | function | Constructs a \Drupal\views\Plugin\Derivative\ViewsLocalTask instance. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.