Commit d50b1695 authored by webchick's avatar webchick

Issue #2115025 by Gábor Hojtsy, pfrenssen, dawehner: Content admin views title...

Issue #2115025 by Gábor Hojtsy, pfrenssen, dawehner: Content admin views title saved localized to the menu table.
parent 4c6309c6
......@@ -2607,6 +2607,9 @@ function menu_router_rebuild() {
* (optional) Save the new router to the database. Defaults to FALSE.
*/
function menu_router_build($save = FALSE) {
// Ensure that all configuration used to build the menu items are loaded
// without overrides.
config_context_enter('config.context.free');
// We need to manually call each module so that we can know which module
// a given item came from.
$callbacks = array();
......@@ -2621,6 +2624,8 @@ function menu_router_build($save = FALSE) {
}
// Alter the menu as defined in modules, keys are like user/%user.
drupal_alter('menu', $callbacks);
// Return to the original context before menu building.
config_context_leave();
foreach ($callbacks as $path => $router_item) {
// If the menu item is a default local task and incorrectly references a
// route, remove it.
......
<?php
/**
* @file
* Contains \Drupal\system\Tests\Menu\MenuRouterRebuildTest.
*/
namespace Drupal\system\Tests\Menu;
use Drupal\simpletest\WebTestBase;
use Drupal\Core\Language\Language;
/**
* Tests menu_router_rebuild().
*/
class MenuRouterRebuildTest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('locale', 'menu_test');
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'Menu router rebuild',
'description' => 'Tests menu_router_rebuild().',
'group' => 'Menu',
);
}
/**
* {@inheritdoc}
*/
function setUp() {
parent::setUp();
$language = new Language(array('id' => 'nl'));
language_save($language);
}
/**
* Tests configuration context when rebuilding the menu router table.
*/
public function testMenuRouterRebuildContext() {
// Enter a language context before rebuilding the menu router tables.
$language_context = config_context_enter('Drupal\Core\Config\Context\LanguageConfigContext');
$language_context->setLanguage(language_load('nl'));
menu_router_rebuild();
// Check that the language context was not used for building the menu item.
$menu_item = menu_get_item('menu-test/context');
$this->assertTrue($menu_item['title'] == 'English', 'Config context overrides are ignored when rebuilding menu router items.');
}
}
......@@ -293,6 +293,11 @@ function menu_test_menu() {
'type' => MENU_LOCAL_TASK,
);
$items['menu-test/context'] = array(
'title' => \Drupal::config('menu_test.menu_item')->get('title'),
'route_name' => 'menu_test.context',
);
return $items;
}
......
......@@ -543,3 +543,10 @@ menu_test.title_test_case4:
_content: '\Drupal\menu_test\Controller\MenuTestController::menuTestCallback'
requirements:
_access: 'TRUE'
menu_test.context:
path: '/menu-test/context'
defaults:
_content: '\Drupal\menu_test\Controller\MenuTestController::menuTestCallback'
requirements:
_access: 'TRUE'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment