function PathPluginBase::getMenuLinks
Same name in other branches
- 9 core/modules/views/src/Plugin/views/display/PathPluginBase.php \Drupal\views\Plugin\views\display\PathPluginBase::getMenuLinks()
- 10 core/modules/views/src/Plugin/views/display/PathPluginBase.php \Drupal\views\Plugin\views\display\PathPluginBase::getMenuLinks()
- 11.x core/modules/views/src/Plugin/views/display/PathPluginBase.php \Drupal\views\Plugin\views\display\PathPluginBase::getMenuLinks()
Overrides DisplayMenuInterface::getMenuLinks
1 call to PathPluginBase::getMenuLinks()
- PathPluginBase::remove in core/
modules/ views/ src/ Plugin/ views/ display/ PathPluginBase.php - Reacts on deleting a display.
File
-
core/
modules/ views/ src/ Plugin/ views/ display/ PathPluginBase.php, line 326
Class
- PathPluginBase
- The base display plugin for path/callbacks. This is used for pages and feeds.
Namespace
Drupal\views\Plugin\views\displayCode
public function getMenuLinks() {
$links = [];
// Replace % with the link to our standard views argument loader
// views_arg_load -- which lives in views.module.
$bits = explode('/', $this->getOption('path'));
// Replace % with %views_arg for menu autoloading and add to the
// page arguments so the argument actually comes through.
foreach ($bits as $pos => $bit) {
if ($bit == '%') {
// If a view requires any arguments we cannot create a static menu link.
return [];
}
}
$path = implode('/', $bits);
$view_id = $this->view->storage
->id();
$display_id = $this->display['id'];
$view_id_display = "{$view_id}.{$display_id}";
$menu_link_id = 'views.' . str_replace('/', '.', $view_id_display);
if ($path) {
$menu = $this->getOption('menu');
if (!empty($menu['type']) && $menu['type'] == 'normal') {
$links[$menu_link_id] = [];
// Some views might override existing paths, so we have to set the route
// name based upon the altering.
$links[$menu_link_id] = [
'route_name' => $this->getRouteName(),
// Identify URL embedded arguments and correlate them to a handler.
'load arguments' => [
$this->view->storage
->id(),
$this->display['id'],
'%index',
],
'id' => $menu_link_id,
];
$links[$menu_link_id]['title'] = $menu['title'];
$links[$menu_link_id]['description'] = $menu['description'];
$links[$menu_link_id]['parent'] = $menu['parent'];
$links[$menu_link_id]['enabled'] = $menu['enabled'];
$links[$menu_link_id]['expanded'] = $menu['expanded'];
if (isset($menu['weight'])) {
$links[$menu_link_id]['weight'] = intval($menu['weight']);
}
// Insert item into the proper menu.
$links[$menu_link_id]['menu_name'] = $menu['menu_name'];
// Keep track of where we came from.
$links[$menu_link_id]['metadata'] = [
'view_id' => $view_id,
'display_id' => $display_id,
];
}
}
return $links;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.