public function ViewsMenuLink::getDerivativeDefinitions in Drupal 8
Same name and namespace in other branches
- 9 core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php \Drupal\views\Plugin\Derivative\ViewsMenuLink::getDerivativeDefinitions()
- 10 core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php \Drupal\views\Plugin\Derivative\ViewsMenuLink::getDerivativeDefinitions()
Gets the definition of all derivatives of a base plugin.
Parameters
array $base_plugin_definition: The definition array of the base plugin.
Return value
array An array of full derivative definitions keyed on derivative id.
Overrides DeriverBase::getDerivativeDefinitions
See also
getDerivativeDefinition()
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) {
list($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;
}