diff --git a/core/lib/Drupal/Core/Menu/LocalTaskManager.php b/core/lib/Drupal/Core/Menu/LocalTaskManager.php index ff3f7de..013dff7 100644 --- a/core/lib/Drupal/Core/Menu/LocalTaskManager.php +++ b/core/lib/Drupal/Core/Menu/LocalTaskManager.php @@ -147,7 +147,7 @@ protected function findDefinitions() { $found_routes[$definition['route_name']] = $definition['tab_root']; } $added_tabs = array(); - foreach ($definitions as $plugin_id => $definition) { + foreach ($definitions as $plugin_id => &$definition) { if (!isset($found_routes[$definition['tab_root']])) { // Create the missing tab. $tabs = $this->createMissingTab($definition); @@ -156,6 +156,12 @@ protected function findDefinitions() { } $added_tabs += $tabs; } + else { + // If a developer adds a new tab and references an existing tab as + // the root, we want to copy that existing tab's root so that the + // value is consistent. + $definition['tab_root'] = $found_routes[$definition['tab_root']]; + } } return $definitions + $added_tabs; } diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php index 6a7c8af..1969937 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php @@ -190,15 +190,17 @@ public function providerTestGetWeight() { // Ensure that a default tab get a lower weight. array( array( - 'tab_root_id' => 'local_task_default', - 'id' => 'local_task_default' + 'tab_root' => 'fake_route.default', + 'route_name' => 'fake_route.default', + 'id' => 'local_task_default', ), -10 ), array( array( - 'tab_root_id' => 'local_task_example', - 'id' => 'local_task_default' + 'tab_root' => 'fake_route.example', + 'route_name' => 'fake_route.default', + 'id' => 'local_task_default', ), 0 ), diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php index f10bb38..641de10 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php @@ -269,20 +269,20 @@ protected function getLocalTaskFixtures() { 'id' => 'menu_local_task_test_tasks_settings', 'route_name' => 'menu_local_task_test_tasks_settings', 'title' => 'Settings', - 'tab_root_id' => 'menu_local_task_test_tasks_view', + 'tab_root' => 'menu_local_task_test_tasks_view', ); $definitions['menu_local_task_test_tasks_edit'] = array( 'id' => 'menu_local_task_test_tasks_edit', 'route_name' => 'menu_local_task_test_tasks_edit', 'title' => 'Settings', - 'tab_root_id' => 'menu_local_task_test_tasks_view', + 'tab_root' => 'menu_local_task_test_tasks_view', 'weight' => 20, ); $definitions['menu_local_task_test_tasks_view'] = array( 'id' => 'menu_local_task_test_tasks_view', 'route_name' => 'menu_local_task_test_tasks_view', 'title' => 'Settings', - 'tab_root_id' => 'menu_local_task_test_tasks_view', + 'tab_root' => 'menu_local_task_test_tasks_view', ); // Add the defaults from the LocalTaskManager. foreach ($definitions as $id => &$info) { @@ -291,7 +291,7 @@ protected function getLocalTaskFixtures() { 'route_name' => '', 'route_parameters' => array(), 'title' => '', - 'tab_root_id' => '', + 'tab_root' => '', 'tab_parent_id' => NULL, 'weight' => 0, 'options' => array(),