public function PathPluginBase::getMenuLinks in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Plugin/views/display/PathPluginBase.php \Drupal\views\Plugin\views\display\PathPluginBase::getMenuLinks()
Gets menu links, if this display provides some.
Return value
array The menu links registers for this display.
Overrides DisplayMenuInterface::getMenuLinks
See also
\Drupal\views\Plugin\Derivative\ViewsMenuLink
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 288 - Contains \Drupal\views\Plugin\views\display\PathPluginBase.
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 = array();
// 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 array();
}
}
$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] = array();
// Some views might override existing paths, so we have to set the route
// name based upon the altering.
$links[$menu_link_id] = array(
'route_name' => $this
->getRouteName(),
// Identify URL embedded arguments and correlate them to a handler.
'load arguments' => array(
$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'];
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'] = array(
'view_id' => $view_id,
'display_id' => $display_id,
);
}
}
return $links;
}