diff -u b/core/lib/Drupal/Core/Menu/ContextualLinkManager.php b/core/lib/Drupal/Core/Menu/ContextualLinkManager.php --- b/core/lib/Drupal/Core/Menu/ContextualLinkManager.php +++ b/core/lib/Drupal/Core/Menu/ContextualLinkManager.php @@ -133,9 +133,9 @@ * @param string $group_name * The group name. * @param array $route_parameters - * The incoming route parameters. This route parameters need to have the - * same name on all contextual link routes, e.g. you cannot use node and - * entity in parallel. + * The incoming route parameters. The route parameters need to have the same + * name on all contextual link routes, e.g. you cannot use node and entity + * in parallel. * * @return array * A list of links as array, keyed by the plugin ID. Each entry is an @@ -169,7 +169,7 @@ ); } - $this->moduleHandler->alter('contextual_links', $links, $group, $route_parameters); + $this->moduleHandler->alter('contextual_links', $links, $group_name, $route_parameters); return $links; } diff -u b/core/modules/menu/menu.module b/core/modules/menu/menu.module --- b/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -94,7 +94,7 @@ $items['admin/structure/menu/manage/%menu/edit'] = array( 'title' => 'Edit menu', 'type' => MENU_DEFAULT_LOCAL_TASK, - 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, + 'context' => MENU_CONTEXT_PAGE, ); $items['admin/structure/menu/item/%menu_link/edit'] = array( 'title' => 'Edit menu link', diff -u b/core/modules/system/system.api.php b/core/modules/system/system.api.php --- b/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -840,6 +840,62 @@ } /** + * Alter contextual links before they are rendered. + * + * This hook is invoked by + * \Drupal\Core\Menu\ContextualLinkManager::getContextualLinkPluginsByGroup(). + * The system-determined contextual links are passed in by reference. Additional + * links may be added and existing links can be altered. + * + * Each contextual link must contain at least: + * - title: The localized title of the link. + * - route_name: The route name of the link. + * - route_parameters: The route parameters of the link. + * - localized_options: An array of options to pass to url(). + * + * @param array $links + * An associative array containing contextual links for the given $group, + * as described above. The array keys are used to build CSS class names for + * contextual links and must therefore be unique for each set of contextual + * links. + * @param string $group + * The group of contextual links being rendered. + * @param array $route_parameters. + * The route parameters passed to each route_name of the contextual links. + * So e.g. it is an array like that: + * @code + * node => $node->id(). + * @endcode + * + * @see \Drupal\Core\Menu\ContextualLinkManager + */ +function hook_contextual_links_alter(array &$links, $group, array $route_parameters) { + if ($group == 'menu') { + // Dynamically use the menu name for the title of the menu_edit contextual + // link. + $menu = \Drupal::entityManager()->getStorageController('menu')->load($route_parameters['menu']); + $links['menu_edit']['title'] = t('Edit menu: !label', array('!label' => $menu->label())); + } +} + +/** + * Alters the plugin definition of contextual links. + * + * @param array $contextual_links + * An array of contextual_links plugin definitions, keyed by contextual link + * ID. Each entry contains the following keys: + * - title: The displayed title of the link + * - route_name: The route_name of the contextual link to be displayed + * - group: The group under which the contextual links should be added to. + * Possible values are e.g. 'node' or 'menu'. + * + * @see \Drupal\Core\Menu\ContextualLinkManager + */ +function hook_contextual_links_plugins_alter(array &$contextual_links) { + $contextual_links['menu_edit']['title'] = 'Edit the menu'; +} + +/** * Perform alterations before a page is rendered. * * Use this hook when you want to remove or alter elements at the page @@ -979,62 +1035,6 @@ } /** - * Alter contextual links before they are rendered. - * - * This hook is invoked by - * \Drupal\Core\Menu\ContextualLinkManager::getContextualLinkPluginsByGroup(). - * The system-determined contextual links are passed in by reference. Additional - * links may be added and existing links can be altered. - * - * Each contextual link must contain at least: - * - title: The localized title of the link. - * - route_name: The route name of the link. - * - route_parameters: The route parameters of the link. - * - localized_options: An array of options to pass to url(). - * - * @param array $links - * An associative array containing contextual links for the given $group, - * as described above. The array keys are used to build CSS class names for - * contextual links and must therefore be unique for each set of contextual - * links. - * @param string $group - * The group of contextual links being rendered. - * @param array $route_parameters. - * The route parameters passed to each route_name of the contextual links. - * So e.g. it is an array like that: - * @code - * node => $node->id(). - * @endcode - * - * @see \Drupal\Core\Menu\ContextualLinkManager - */ -function hook_contextual_links_alter(array &$links, $group, array $route_parameters) { - if ($group == 'menu') { - // Dynamically use the menu name for the title of the menu_edit contextual - // link. - $menu = \Drupal::entityManager()->getStorageController('menu')->load($route_parameters['menu']); - $links['menu_edit']['title'] = t('Edit menu: @label', array('@label' => $menu->label())); - } -} - -/** - * Alters the plugin definition of contextual links. - * - * @param array $contextual_links - * An array of contextual_links plugin definitions, keyed by contextual link - * ID. Each entry contains the following keys: - * - title: The displayed title of the link - * - route_name: The route_name of the contextual link to be displayed - * - group: The group under which the contextual links should be added to. - * Possible values are e.g. 'node' or 'menu'. - * - * @see \Drupal\Core\Menu\ContextualLinkManager - */ -function hook_contextual_links_plugins_alter(array &$contextual_links) { - $contextual_links['menu_edit']['title'] = 'Edit the menu'; -} - -/** * Perform alterations before a page is rendered. * * Use this hook when you want to remove or alter elements at the page diff -u b/core/modules/taxonomy/lib/Drupal/taxonomy/TermRenderController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermRenderController.php --- b/core/modules/taxonomy/lib/Drupal/taxonomy/TermRenderController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermRenderController.php @@ -54,7 +54,7 @@ protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplay $display, $view_mode, $langcode = NULL) { parent::alterBuild($build, $entity, $display, $view_mode, $langcode); $build['#attached']['css'][] = drupal_get_path('module', 'taxonomy') . '/css/taxonomy.module.css'; - $build['#contextual_links']['taxonomy'] = array('taxonomy/term', array( + $build['#contextual_links']['taxonomy'] = array('taxonomy_term', array( 'taxonomy_term' => $entity->id(), )); } diff -u b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php --- b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php @@ -289,7 +289,12 @@ ->method('createInstance') ->will($this->returnValueMap($map)); + $this->moduleHandler->expects($this->at(1)) + ->method('alter') + ->with($this->equalTo('contextual_links'), new \PHPUnit_Framework_Constraint_Count(2), $this->equalTo('group1'), $this->equalTo(array('key' => 'value'))); + $result = $this->contextualLinkManager->getContextualLinksArrayByGroup('group1', array('key' => 'value')); + $this->assertCount(2, $result); foreach (array('test_plugin1', 'test_plugin2') as $plugin_id) { $definition = $definitions[$plugin_id]; $this->assertEquals($definition['weight'], $result[$plugin_id]['weight']); only in patch2: unchanged: --- /dev/null +++ b/core/modules/node/node.contextual_links.yml @@ -0,0 +1,10 @@ +node.page_edit: + route_name: node.page_edit + group: node + title: Edit + +node.delete_confirm: + route_name: node.delete_confirm + group: node + title: Delete + weight: 10 only in patch2: unchanged: --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1027,14 +1027,7 @@ function node_menu() { 'title' => 'Edit', 'route_name' => 'node.page_edit', 'type' => MENU_LOCAL_TASK, - 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, - ); - $items['node/%node/delete'] = array( - 'title' => 'Delete', - 'route_name' => 'node.delete_confirm', - 'weight' => 10, - 'type' => MENU_LOCAL_TASK, - 'context' => MENU_CONTEXT_INLINE, + 'context' => MENU_CONTEXT_PAGE, ); $items['node/%node/revisions'] = array( 'title' => 'Revisions', only in patch2: unchanged: --- /dev/null +++ b/core/modules/system/tests/modules/menu_test/menu_test.contextual_links.yml @@ -0,0 +1,14 @@ +menu_test.hidden_manage: + title: 'List links' + group: menu_test_menu + route_name: menu_test.hidden_manage + +menu_test.hidden_manage: + title: 'Edit menu' + group: menu_test_menu + route_name: menu_test.hidden_manage_edit + +menu_test.hidden_block_configure: + title: 'Configure block' + group: menu_test_block + route_name: menu_test.hidden_block_configure only in patch2: unchanged: --- a/core/modules/system/tests/modules/menu_test/menu_test.module +++ b/core/modules/system/tests/modules/menu_test/menu_test.module @@ -126,7 +126,7 @@ function menu_test_menu() { $items['menu-test/hidden/menu/manage/%menu/list'] = array( 'title' => 'List links', 'type' => MENU_DEFAULT_LOCAL_TASK, - 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, + 'context' => MENU_CONTEXT_PAGE, ); $items['menu-test/hidden/menu/manage/%menu/add'] = array( 'title' => 'Add link', @@ -137,7 +137,7 @@ function menu_test_menu() { 'title' => 'Edit menu', 'route_name' => 'menu_test.hidden_manage_edit', 'type' => MENU_LOCAL_TASK, - 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, + 'context' => MENU_CONTEXT_PAGE, ); $items['menu-test/hidden/menu/manage/%menu/delete'] = array( 'title' => 'Delete menu', @@ -162,11 +162,6 @@ function menu_test_menu() { 'title' => 'Configure block', 'route_name' => 'menu_test.hidden_block_configure', ); - $items['menu-test/hidden/block/manage/%/%/configure'] = array( - 'title' => 'Configure block', - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'context' => MENU_CONTEXT_INLINE, - ); $items['menu-test/hidden/block/manage/%/%/delete'] = array( 'title' => 'Delete block', 'route_name' => 'menu_test.hidden_block_delete', only in patch2: unchanged: --- /dev/null +++ b/core/modules/taxonomy/taxonomy.contextual_links.yml @@ -0,0 +1,17 @@ +taxonomy.term_edit: + title: Edit + group: taxonomy_term + route_name: taxonomy.term_edit + weight: 10 + +taxonomy.term_delete: + title: Delete + group: taxonomy_term + route_name: taxonomy.term_delete + weight: 20 + +taxonomy.vocabulary_delete: + title: Delete + group: taxonomy_vocabulary + route_name: taxonomy.vocabulary_delete + weight: 20 only in patch2: unchanged: --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -263,16 +263,9 @@ function taxonomy_menu() { 'title' => 'Edit', 'route_name' => 'taxonomy.term_edit', 'type' => MENU_LOCAL_TASK, - 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, + 'context' => MENU_CONTEXT_PAGE, 'weight' => 10, ); - $items['taxonomy/term/%taxonomy_term/delete'] = array( - 'title' => 'Delete', - 'type' => MENU_LOCAL_TASK, - 'context' => MENU_CONTEXT_INLINE, - 'weight' => 20, - 'route_name' => 'taxonomy.term_delete', - ); $items['taxonomy/term/%taxonomy_term/feed'] = array( 'title' => 'Taxonomy term', 'title callback' => 'taxonomy_term_title', @@ -295,13 +288,6 @@ function taxonomy_menu() { 'route_name' => 'taxonomy.vocabulary_edit', 'type' => MENU_LOCAL_TASK, ); - $items['admin/structure/taxonomy/%taxonomy_vocabulary/delete'] = array( - 'title' => 'Delete', - 'type' => MENU_LOCAL_TASK, - 'context' => MENU_CONTEXT_INLINE, - 'weight' => 20, - 'route_name' => 'taxonomy.vocabulary_delete', - ); $items['admin/structure/taxonomy/manage/%taxonomy_vocabulary/add'] = array( 'title' => 'Add term', only in patch2: unchanged: --- /dev/null +++ b/core/modules/user/user.contextual_links.yml @@ -0,0 +1,5 @@ +user.role_delete: + title: 'Delete role' + group: role + weight: 10 + route_name: 'user.role_delete' only in patch2: unchanged: --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -807,12 +807,6 @@ function user_menu() { 'title' => 'Edit', 'type' => MENU_DEFAULT_LOCAL_TASK, ); - $items['admin/people/roles/manage/%user_role/delete'] = array( - 'title' => 'Delete role', - 'route_name' => 'user.role_delete', - 'weight' => 10, - 'context' => MENU_CONTEXT_INLINE, - ); // Administration pages. $items['admin/config/people'] = array(