diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsLocalTask.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsLocalTask.php new file mode 100644 index 0000000..f92c183 --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsLocalTask.php @@ -0,0 +1,72 @@ +routeProvider = \Drupal::service('router.route_provider'); + } + + + /** + * {@inheritdoc} + */ + public function getDerivativeDefinitions(array $base_plugin_definition) { + $this->derivatives = array(); + foreach (views_get_applicable_views('uses_hook_menu') as $pair) { + /** @var $executable \Drupal\views\ViewExecutable */ + list($executable, $display_id) = $pair; + + $executable->setDisplay($display_id); + $menu = $executable->display_handler->getOption('menu'); + if (in_array($menu['type'], array('tab', 'default tab'))) { + $route_name = $plugin_id = 'view.' . $executable->storage->id() . '.' . $display_id; + $this->derivatives[$plugin_id] = array( + 'route_name' => $route_name, + 'class' => 'Drupal\views\Plugin\Menu\LocalTask\ViewsLocalTask', + 'weight' => $menu['weight'] + ); + + // Find out the parent route. + // @todo Find out how to find both the root and parent tab. + $path = $executable->display_handler->getPath(); + $split = explode('/', $path); + array_pop($split); + $path = implode('/', $split); + $pattern = '/' . str_replace('%', '{}', $path); + if ($routes = $this->routeProvider->getRoutesByPattern($pattern)) { + foreach ($routes->all() as $name => $route) { + // @TODO So good so far, from the route name we would get the parent + // local ask, which might be defined by views or by other plugins. + $this->derivatives[$plugin_id]['tab_root_id'] = $name; + // Skip after the first found route. + break; + } + } + } + } + return $this->derivatives; + } + +} diff --git a/core/modules/views/lib/Drupal/views/Plugin/Menu/LocalTask/ViewsLocalTask.php b/core/modules/views/lib/Drupal/views/Plugin/Menu/LocalTask/ViewsLocalTask.php new file mode 100644 index 0000000..9c43e5f --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Plugin/Menu/LocalTask/ViewsLocalTask.php @@ -0,0 +1,22 @@ +