diff -u b/core/modules/action/src/ActionFormBase.php b/core/modules/action/src/ActionFormBase.php --- b/core/modules/action/src/ActionFormBase.php +++ b/core/modules/action/src/ActionFormBase.php @@ -7,14 +7,14 @@ namespace Drupal\action; -use Drupal\Core\Entity\EntityForm; +use Drupal\Core\Entity\ConfigEntityForm; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\PluginFormInterface; /** * Provides a base form for action forms. */ -abstract class ActionFormBase extends EntityForm { +abstract class ActionFormBase extends ConfigEntityForm { /** * The action plugin being configured. reverted: --- b/core/modules/shortcut/src/Form/SwitchShortcutSet.php +++ a/core/modules/shortcut/src/Form/SwitchShortcutSet.php @@ -7,7 +7,7 @@ namespace Drupal\shortcut\Form; +use Drupal\Core\Form\FormBase; -use Drupal\Core\Entity\ConfigEntityForm; use Drupal\Core\Form\FormStateInterface; use Drupal\shortcut\Entity\ShortcutSet; use Drupal\shortcut\ShortcutSetStorageInterface; @@ -17,7 +17,7 @@ /** * Builds the shortcut set switch form. */ +class SwitchShortcutSet extends FormBase { -class SwitchShortcutSet extends ConfigEntityForm { /** * The account the shortcut set is for. @@ -106,7 +106,7 @@ $form['id'] = array( '#type' => 'machine_name', '#machine_name' => array( + 'exists' => array($this, 'exists'), - 'exists' => [static::class, 'exists'], 'replace_pattern' => '[^a-z0-9-]+', 'replace' => '-', ), @@ -142,6 +142,21 @@ } /** + * Determines if a shortcut set exists already. + * + * @param string $id + * The set ID to check. + * + * @return bool + * TRUE if the shortcut set exists, FALSE otherwise. + */ + public function exists($id) { + return (bool) $this->shortcutSetStorage->getQuery() + ->condition('id', $id) + ->execute(); + } + + /** * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) {