Commit b08fe47a authored by webchick's avatar webchick

Issue #945654 by Gábor Hojtsy, sun, VVVi, David_Rothstein: Fixed Default menus...

Issue #945654 by Gábor Hojtsy, sun, VVVi, David_Rothstein: Fixed Default menus have hardcoded titles which cannot be edited.
parent c9a273af
...@@ -28,8 +28,6 @@ public function form(array $form, array &$form_state, EntityInterface $menu) { ...@@ -28,8 +28,6 @@ public function form(array $form, array &$form_state, EntityInterface $menu) {
'#title' => t('Title'), '#title' => t('Title'),
'#default_value' => $menu->label(), '#default_value' => $menu->label(),
'#required' => TRUE, '#required' => TRUE,
// The title of a system menu cannot be altered.
'#access' => !isset($system_menus[$menu->id()]),
); );
$form['id'] = array( $form['id'] = array(
'#type' => 'machine_name', '#type' => 'machine_name',
......
...@@ -283,6 +283,22 @@ function testMenuQueryAndFragment() { ...@@ -283,6 +283,22 @@ function testMenuQueryAndFragment() {
$this->assertFieldByName('link_path', $path, 'Path no longer has query or fragment.'); $this->assertFieldByName('link_path', $path, 'Path no longer has query or fragment.');
} }
/**
* Test renaming built-in menu.
*/
function testSystemMenuRename() {
$this->drupalLogin($this->big_user);
$edit = array(
'label' => $this->randomName(16),
);
$this->drupalPost('admin/structure/menu/manage/main/edit', $edit, t('Save'));
// Make sure menu shows up with new name in block addition.
$default_theme = variable_get('theme_default', 'stark');
$this->drupalget('admin/structure/block/list/block_plugin_ui:' . $default_theme . '/add');
$this->assertText($edit['label']);
}
/** /**
* Add a menu link using the menu module UI. * Add a menu link using the menu module UI.
* *
......
...@@ -221,7 +221,7 @@ function menu_overview_form_submit($complete_form, &$form_state) { ...@@ -221,7 +221,7 @@ function menu_overview_form_submit($complete_form, &$form_state) {
// parent. To prevent this, save items in the form in the same order they // parent. To prevent this, save items in the form in the same order they
// are sent, ensuring parents are saved first, then their children. // are sent, ensuring parents are saved first, then their children.
// See http://drupal.org/node/181126#comment-632270 // See http://drupal.org/node/181126#comment-632270
$order = array_flip(array_keys($input)); $order = is_array($input) ? array_flip(array_keys($input)) : array();
// Update our original form with the new order. // Update our original form with the new order.
$form = array_intersect_key(array_merge($order, $form), $form); $form = array_intersect_key(array_merge($order, $form), $form);
......
...@@ -42,11 +42,14 @@ public function getDerivativeDefinitions(array $base_plugin_definition) { ...@@ -42,11 +42,14 @@ public function getDerivativeDefinitions(array $base_plugin_definition) {
foreach (menu_list_system_menus() as $menu => $name) { foreach (menu_list_system_menus() as $menu => $name) {
// The block deltas need to be prefixed with 'menu-', since the 'main' // The block deltas need to be prefixed with 'menu-', since the 'main'
// menu would otherwise clash with the 'main' page content block. // menu would otherwise clash with the 'main' page content block.
$menu = "menu-$menu"; $menu_key = 'menu-' . $menu;
$this->derivatives[$menu] = $base_plugin_definition; $this->derivatives[$menu_key] = $base_plugin_definition;
$this->derivatives[$menu]['delta'] = $menu; $this->derivatives[$menu_key]['delta'] = $menu_key;
$this->derivatives[$menu]['admin_label'] = $name; // It is possible that users changed the menu label. Fall back on the
$this->derivatives[$menu]['cache'] = DRUPAL_NO_CACHE; // built-in menu label if the entity was not found.
$entity = entity_load('menu', $menu);
$this->derivatives[$menu_key]['admin_label'] = !empty($entity) ? $entity->label() : $name;
$this->derivatives[$menu_key]['cache'] = DRUPAL_NO_CACHE;
} }
return $this->derivatives; return $this->derivatives;
} }
......
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