diff --git a/core/modules/comment/comment.local_tasks.yml b/core/modules/comment/comment.local_tasks.yml index 3119823..baba52c 100644 --- a/core/modules/comment/comment.local_tasks.yml +++ b/core/modules/comment/comment.local_tasks.yml @@ -13,3 +13,21 @@ comment.confirm_delete_tab: tab_root_id: comment.permalink_tab weight: 10 +comment.admin: + title: Comments + route_name: comment.admin + tab_root_id: node.content_overview + +comment.admin_new: + title: 'Published comments' + route_name: comment.admin + tab_root_id: node.content_overview + tab_parent_id: comment.admin + +comment.admin_approval: + title: 'Unapproved comments' + route_name: comment.admin_approval + class: Drupal\comment\Plugin\Menu\LocalTask\UnapprovedComments + tab_root_id: node.content_overview + tab_parent_id: comment.admin + weight: 1 diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 4ffcb4b..72cba00 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -210,18 +210,7 @@ function comment_menu() { 'title' => 'Comments', 'description' => 'List and edit site comments and the comment approval queue.', 'route_name' => 'comment.admin', - 'type' => MENU_LOCAL_TASK | MENU_NORMAL_ITEM, - ); - // Tabs begin here. - $items['admin/content/comment/new'] = array( - 'title' => 'Published comments', - 'type' => MENU_DEFAULT_LOCAL_TASK, - ); - $items['admin/content/comment/approval'] = array( - 'title' => 'Unapproved comments', - 'title callback' => 'comment_count_unpublished', - 'route_name' => 'comment.admin_approval', - 'type' => MENU_LOCAL_TASK, + 'type' => MENU_NORMAL_ITEM, ); return $items; diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Menu/LocalTask/UnapprovedComments.php b/core/modules/comment/lib/Drupal/comment/Plugin/Menu/LocalTask/UnapprovedComments.php index babb881..a92fe71 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Menu/LocalTask/UnapprovedComments.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Menu/LocalTask/UnapprovedComments.php @@ -46,7 +46,10 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) { - return new static($configuration, $plugin_id, $plugin_definition, + return new static( + $configuration, + $plugin_id, + $plugin_definition, $container->get('database') ); } @@ -61,4 +64,4 @@ public function getTitle() { return $this->t('Unapproved comments (@count)', array('@count' => $count)); } -} +} diff --git a/core/modules/node/node.local_tasks.yml b/core/modules/node/node.local_tasks.yml index 24d9ef2..eb7105c 100644 --- a/core/modules/node/node.local_tasks.yml +++ b/core/modules/node/node.local_tasks.yml @@ -16,3 +16,7 @@ node.revision_overview: tab_root_id: node.view title: 'Revisions' weight: 20 +node.content_overview: + title: Content + route_name: node.content_overview + tab_root_id: node.content_overview diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 4fe1645..9b8cd78 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -934,10 +934,6 @@ function node_menu() { 'route_name' => 'node.content_overview', 'weight' => -10, ); - $items['admin/content/node'] = array( - 'title' => 'Content', - 'type' => MENU_DEFAULT_LOCAL_TASK, - ); $items['admin/structure/types'] = array( 'title' => 'Content types', diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsLocalTask.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsLocalTask.php index 1a3eb58..98a3957 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsLocalTask.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsLocalTask.php @@ -11,6 +11,7 @@ use Drupal\Core\KeyValueStore\KeyValueStoreInterface; use Drupal\Core\Plugin\Discovery\ContainerDerivativeInterface; use Drupal\Core\Routing\RouteProviderInterface; +use Drupal\views\Views; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -146,11 +147,11 @@ public function alterLocalTasks(&$local_tasks) { * @param array $local_tasks * An array of all local task definitions. * - * @return bool|string - * Returns the local task ID of the parent task, otherwise return FALSE. + * @return NULL|string + * Returns the local task ID of the parent task, otherwise NULL. */ protected function getPluginIdFromRoute($route_name, &$local_tasks) { - $local_task_id = FALSE; + $local_task_id = NULL; foreach ($local_tasks as $plugin_id => $local_task) { if ($local_task['route_name'] == $route_name) { $local_task_id = $plugin_id; @@ -174,7 +175,7 @@ protected function getPluginIdFromRoute($route_name, &$local_tasks) { * @endcode */ protected function getApplicableMenuViews() { - return views_get_applicable_views('uses_hook_menu'); + return Views::getApplicableViews('hook_menu'); } } 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 731f604..cd8e066 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 @@ -293,18 +293,20 @@ public function executeHookMenu($callbacks) { // Insert item into the proper menu. $items[$path]['menu_name'] = $menu['name']; break; - case 'tab': - $items[$path]['type'] = MENU_LOCAL_TASK; - break; - case 'default tab': - $items[$path]['type'] = MENU_DEFAULT_LOCAL_TASK; - break; } // Add context for contextual links. // @see menu_contextual_links() - if (!empty($menu['context'])) { - $items[$path]['context'] = MENU_CONTEXT_INLINE; + if (in_array($menu['type'], array('tab', 'default tab'))) { + // @todo Remove once contextual links are ported to a new plugin based + // system. + if (!empty($menu['context'])) { + $items[$path]['context'] = MENU_CONTEXT_INLINE; + $items[$path]['type'] = MENU_LOCAL_TASK; + } + else { + $items[$path]['type'] = MENU_CALLBACK; + } } // If this is a 'default' tab, check to see if we have to create the @@ -339,9 +341,6 @@ public function executeHookMenu($callbacks) { case 'normal': $items[$default_path]['type'] = MENU_NORMAL_ITEM; break; - case 'tab': - $items[$default_path]['type'] = MENU_LOCAL_TASK; - break; } if (isset($tab_options['weight'])) { $items[$default_path]['weight'] = intval($tab_options['weight']); diff --git a/core/modules/views/views.module b/core/modules/views/views.module index edc5ec1..449e864 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -12,6 +12,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Database\Query\AlterableInterface; use Drupal\Core\Language\Language; +use Drupal\views\Plugin\Derivative\ViewsLocalTask; use Drupal\views\ViewExecutable; use Drupal\Component\Plugin\Exception\PluginException; use Drupal\views\Entity\View; @@ -1600,3 +1601,11 @@ function views_cache_get($cid, $use_language = FALSE) { return cache('views_info')->get($cid); } +/** + * Implements hook_local_tasks_alter(). + */ +function views_local_tasks_alter(&$local_tasks) { + $container = \Drupal::getContainer(); + $local_task = ViewsLocalTask::create($container, 'views_view'); + $local_task->alterLocalTasks($local_tasks); +}