diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php index 45df603..57691f1 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php @@ -27,6 +27,29 @@ public function hasPath() { } /** + * {@inheritdoc} + */ + public function getPath() { + $bits = explode('/', $this->getOption('path')); + if ($this->isDefaultTabPath()) { + array_pop($bits); + } + return implode('/', $bits); + } + + /** + * Determines if this display's path is a default tab. + * + * @return bool + * TRUE if the display path is for a default tab, FALSE otherwise. + */ + protected function isDefaultTabPath() { + $menu = $this->getOption('menu'); + $tab_options = $this->getOption('tab_options'); + return $menu['type'] == 'default tab' && !empty($tab_options['type']) && $tab_options['type'] != 'none'; + } + + /** * Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase:defineOptions(). */ protected function defineOptions() { @@ -85,9 +108,7 @@ public function collectRoutes(RouteCollection $collection) { } // If this is to be a default tab, create the route for the parent path. - $menu = $this->getOption('menu'); - $tab_options = $this->getOption('tab_options'); - if ($menu['type'] == 'default tab' && !empty($tab_options['type']) && $tab_options['type'] != 'none') { + if ($this->isDefaultTabPath()) { $bit = array_pop($bits); if ($bit == '%views_arg' || empty($bits)) { $bits[] = $bit; @@ -182,9 +203,9 @@ public function executeHookMenu($callbacks) { // If this is a 'default' tab, check to see if we have to create the // parent menu item. - if ($menu['type'] == 'default tab') { + if ($this->isDefaultTabPath()) { $tab_options = $this->getOption('tab_options'); - if (!empty($tab_options['type']) && $tab_options['type'] != 'none') { + $bits = explode('/', $path); // Remove the last piece. $bit = array_pop($bits); @@ -222,7 +243,6 @@ public function executeHookMenu($callbacks) { } } } - } return $items; }