class ViewsMenuLink in Drupal 10
Same name in this branch
- 10 core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php \Drupal\views\Plugin\Derivative\ViewsMenuLink
- 10 core/modules/views/src/Plugin/Menu/ViewsMenuLink.php \Drupal\views\Plugin\Menu\ViewsMenuLink
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php \Drupal\views\Plugin\Derivative\ViewsMenuLink
- 9 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 DeriverInterface
- class \Drupal\views\Plugin\Derivative\ViewsMenuLink implements 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;
}
}