public function ViewsMenuLink::getDerivativeDefinitions in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php \Drupal\views\Plugin\Derivative\ViewsMenuLink::getDerivativeDefinitions()
- 9 core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php \Drupal\views\Plugin\Derivative\ViewsMenuLink::getDerivativeDefinitions()
File
- core/
modules/ views/ src/ Plugin/ Derivative/ ViewsMenuLink.php, line 48
Class
- ViewsMenuLink
- Provides menu links for Views.
Namespace
Drupal\views\Plugin\DerivativeCode
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;
}