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 430a612..c917cc9 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 = 'The %entity_type with the %field_name %value already exists.'; + public $message = 'The @entity_type with the @field_name %value already exists.'; /** * {@inheritdoc} diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldValueValidator.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldValueValidator.php index 6fbf559..1917c5c 100644 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldValueValidator.php +++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldValueValidator.php @@ -40,8 +40,8 @@ public function validate($items, Constraint $constraint) { if ($value_taken) { $this->context->addViolation($constraint->message, [ '%value' => $item->value, - '%entity_type' => $entity->getEntityType()->getLowercaseLabel(), - '%field_name' => Unicode::strtolower($items->getFieldDefinition()->getLabel()), + '@entity_type' => $entity->getEntityType()->getLowercaseLabel(), + '@field_name' => Unicode::strtolower($items->getFieldDefinition()->getLabel()), ]); } } diff --git a/core/modules/block_content/src/Entity/BlockContent.php b/core/modules/block_content/src/Entity/BlockContent.php index 37b343d..40c19e9 100644 --- a/core/modules/block_content/src/Entity/BlockContent.php +++ b/core/modules/block_content/src/Entity/BlockContent.php @@ -188,7 +188,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { 'weight' => -5, )) ->setDisplayConfigurable('form', TRUE) - ->addConstraint('UniqueField', ['message' => '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 d2bef6e..66c259a 100644 --- a/core/modules/block_content/src/Tests/BlockContentCreationTest.php +++ b/core/modules/block_content/src/Tests/BlockContentCreationTest.php @@ -66,8 +66,8 @@ 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 %name already exists.', array( - '%name' => $edit['info[0][value]'] + $this->assertRaw(format_string('The custom block with the block description %value already exists.', array( + '%value' => $edit['info[0][value]'] ))); $this->assertResponse(200); } @@ -124,7 +124,7 @@ public function testBlockContentCreationMultipleViewModes() { $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('The custom block with the 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..e13f010 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('The custom block with the 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 0405303..2952bce 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -477,7 +477,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('Email')) ->setDescription(t('The email of this user.')) ->setDefaultValue('') - ->addConstraint('UniqueField', []) + ->addConstraint('UniqueField') ->addConstraint('UserMailRequired') ->addConstraint('ProtectedUserField');