Issue #2428891 by kgoel: Remove unnecessary unique label validation for shortcut sets

8.0.x
Alex Pott 2015-02-27 17:49:35 +00:00
parent a2af0ed804
commit 1dccb94620
4 changed files with 2 additions and 28 deletions

View File

@ -227,6 +227,8 @@ function shortcut_default_set($account = NULL) {
*
* @return
* TRUE if a shortcut set with that title exists; FALSE otherwise.
*
* @deprecated in Drupal 8.x, will be removed before Drupal 9.0.
*/
function shortcut_set_title_exists($title) {
$sets = ShortcutSet::loadMultiple();

View File

@ -175,10 +175,6 @@ class SwitchShortcutSet extends FormBase {
if (trim($form_state->getValue('label')) == '') {
$form_state->setErrorByName('new', $this->t('The new set label is required.'));
}
// Check to prevent a duplicate title.
if (shortcut_set_title_exists($form_state->getValue('label'))) {
$form_state->setErrorByName('label', $this->t('The shortcut set %name already exists. Choose another name.', array('%name' => $form_state->getValue('label'))));
}
}
}

View File

@ -48,18 +48,6 @@ class ShortcutSetForm extends EntityForm {
return $form;
}
/**
* {@inheritdoc}
*/
public function validate(array $form, FormStateInterface $form_state) {
parent::validate($form, $form_state);
$entity = $this->entity;
// Check to prevent a duplicate title.
if ($form_state->getValue('label') != $entity->label() && shortcut_set_title_exists($form_state->getValue('label'))) {
$form_state->setErrorByName('label', $this->t('The shortcut set %name already exists. Choose another name.', array('%name' => $form_state->getValue('label'))));
}
}
/**
* {@inheritdoc}
*/

View File

@ -150,18 +150,6 @@ class ShortcutSetsTest extends ShortcutTestBase {
$this->assertTrue($set->label() == $new_label, 'Shortcut set has been successfully renamed.');
}
/**
* Tests renaming a shortcut set to the same name as another set.
*/
function testShortcutSetRenameAlreadyExists() {
$set = $this->generateShortcutSet($this->randomMachineName());
$existing_label = $this->set->label();
$this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $set->id(), array('label' => $existing_label), t('Save'));
$this->assertRaw(t('The shortcut set %name already exists. Choose another name.', array('%name' => $existing_label)));
$set = ShortcutSet::load($set->id());
$this->assertNotEqual($set->label(), $existing_label, format_string('The shortcut set %title cannot be renamed to %new-title because a shortcut set with that title already exists.', array('%title' => $set->label(), '%new-title' => $existing_label)));
}
/**
* Tests unassigning a shortcut set.
*/