diff --git a/core/lib/Drupal/Core/Field/FieldConfigInterface.php b/core/lib/Drupal/Core/Field/FieldConfigInterface.php index f5a86a6..79486d8 100644 --- a/core/lib/Drupal/Core/Field/FieldConfigInterface.php +++ b/core/lib/Drupal/Core/Field/FieldConfigInterface.php @@ -178,7 +178,7 @@ public function addPropertyConstraints($name, array $constraints); * @code * // Add a constraint to the 'field_username' FieldItemList. * // e.g. $node->field_username - * $fields['field_username']->addConstraint('UniqueField', ['message' => t('The username %value is already taken.')]); + * $fields['field_username']->addConstraint('UniqueField'); * @endcode * * If you wish to apply a constraint to a \Drupal\Core\Field\FieldItem instead diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldConstraint.php index da58934..770b375 100644 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldConstraint.php +++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldConstraint.php @@ -19,7 +19,7 @@ */ class UniqueFieldConstraint extends Constraint { - public $message = 'A @entity_type with the @field_name %value already exists.'; + public $message = 'A @entity_type with @field_name %value already exists.'; /** * {@inheritdoc} diff --git a/core/modules/aggregator/src/Entity/Feed.php b/core/modules/aggregator/src/Entity/Feed.php index fc1b9ee..68effd4 100644 --- a/core/modules/aggregator/src/Entity/Feed.php +++ b/core/modules/aggregator/src/Entity/Feed.php @@ -151,7 +151,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { 'weight' => -5, )) ->setDisplayConfigurable('form', TRUE) - ->addConstraint('UniqueField', ['message' => t('A feed named %value already exists. Enter a unique title.')]); + ->addConstraint('FeedTitle'); $fields['langcode'] = BaseFieldDefinition::create('language') ->setLabel(t('Language code')) @@ -173,7 +173,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { 'weight' => -3, )) ->setDisplayConfigurable('form', TRUE) - ->addConstraint('UniqueField', ['message' => t('A feed with this URL %value already exists. Enter a unique URL.')]); + ->addConstraint('FeedUrl'); $intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200); $period = array_map(array(\Drupal::service('date.formatter'), 'formatInterval'), array_combine($intervals, $intervals)); diff --git a/core/modules/block_content/src/Entity/BlockContent.php b/core/modules/block_content/src/Entity/BlockContent.php index 8680ffc..f679aba 100644 --- a/core/modules/block_content/src/Entity/BlockContent.php +++ b/core/modules/block_content/src/Entity/BlockContent.php @@ -190,7 +190,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { 'weight' => -5, )) ->setDisplayConfigurable('form', TRUE) - ->addConstraint('UniqueField', ['message' => t('A block with description %value already exists.')]); + ->addConstraint('UniqueField'); $fields['type'] = BaseFieldDefinition::create('entity_reference') ->setLabel(t('Block type')) diff --git a/core/modules/block_content/src/Tests/BlockContentCreationTest.php b/core/modules/block_content/src/Tests/BlockContentCreationTest.php index 7afb177..321c451 100644 --- a/core/modules/block_content/src/Tests/BlockContentCreationTest.php +++ b/core/modules/block_content/src/Tests/BlockContentCreationTest.php @@ -66,7 +66,7 @@ public function testBlockContentCreation() { $this->drupalPostForm('block/add/basic', $edit, t('Save')); // Check that the Basic block has been created. - $this->assertRaw(format_string('A block with description %value already exists.', array( + $this->assertRaw(format_string('A custom block with block description %value already exists.', array( '%value' => $edit['info[0][value]'] ))); $this->assertResponse(200); diff --git a/core/modules/block_content/src/Tests/BlockContentValidationTest.php b/core/modules/block_content/src/Tests/BlockContentValidationTest.php index 85bf6e9..d5ebde2 100644 --- a/core/modules/block_content/src/Tests/BlockContentValidationTest.php +++ b/core/modules/block_content/src/Tests/BlockContentValidationTest.php @@ -37,7 +37,7 @@ public function testValidation() { // Make sure the violation is on the info property $this->assertEqual($violations[0]->getPropertyPath(), 'info'); // Make sure the message is correct. - $this->assertEqual($violations[0]->getMessage(), format_string('A block with description %value already exists.', [ + $this->assertEqual($violations[0]->getMessage(), format_string('A custom block with block description %value already exists.', [ '%value' => $block->label(), ])); } diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php index 03b0ba4..53155a0 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -468,7 +468,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { // No Length constraint here because the UserName constraint also covers // that. 'UserName' => array(), - 'UniqueField' => array('message' => t('The username %value is already taken.')), + 'UserNameUnique' => array(), )); $fields['pass'] = BaseFieldDefinition::create('password') @@ -480,7 +480,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('Email')) ->setDescription(t('The email of this user.')) ->setDefaultValue('') - ->addConstraint('UniqueField', ['message' => t('The email address %value is already taken.')]) + ->addConstraint('UserMailUnique') ->addConstraint('UserMailRequired') ->addConstraint('ProtectedUserField');