summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-06-11 10:51:06 (GMT)
committerAlex Pott2015-06-11 10:51:06 (GMT)
commit3b62b84f4e68ea1ad44894b8b5a663e8570c9d3d (patch)
tree0152f638bd6a61d837b99f815a70533c2131333f
parent1144f4797069c0442f965e3fc22b5f4395b85cd0 (diff)
Issue #2195083 by Les Lim, ParisLiakos, Xano, gaurav_varshney, ravi.khetri, fago, jain_deepak: Add a dedicated @Constraint annotation class
-rw-r--r--core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraint.php2
-rw-r--r--core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraint.php2
-rw-r--r--core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraint.php4
-rw-r--r--core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraint.php2
-rw-r--r--core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ValidReferenceConstraint.php2
-rw-r--r--core/lib/Drupal/Core/Validation/Annotation/Constraint.php57
-rw-r--r--core/lib/Drupal/Core/Validation/ConstraintManager.php15
-rw-r--r--core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraint.php4
-rw-r--r--core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php4
-rw-r--r--core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/CountConstraint.php2
-rw-r--r--core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php2
-rw-r--r--core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/IsNullConstraint.php2
-rw-r--r--core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php2
-rw-r--r--core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/NotNullConstraint.php2
-rw-r--r--core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraint.php2
-rw-r--r--core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RangeConstraint.php2
-rw-r--r--core/modules/aggregator/src/Plugin/Validation/Constraint/FeedTitleConstraint.php2
-rw-r--r--core/modules/aggregator/src/Plugin/Validation/Constraint/FeedUrlConstraint.php2
-rw-r--r--core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraint.php2
-rw-r--r--core/modules/field/tests/modules/field_test/src/Plugin/Validation/Constraint/TestFieldConstraint.php2
-rw-r--r--core/modules/forum/src/Plugin/Validation/Constraint/ForumLeafConstraint.php2
-rw-r--r--core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraint.php2
-rw-r--r--core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraint.php2
-rw-r--r--core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraint.php2
-rw-r--r--core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php2
-rw-r--r--core/modules/system/core.api.php13
-rw-r--r--core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/EntityTestCompositeConstraint.php2
-rw-r--r--core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/EntityTestEntityLevel.php2
-rw-r--r--core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/FieldWidgetConstraint.php2
-rw-r--r--core/modules/user/src/Plugin/Validation/Constraint/ProtectedUserFieldConstraint.php2
-rw-r--r--core/modules/user/src/Plugin/Validation/Constraint/UserMailRequired.php2
-rw-r--r--core/modules/user/src/Plugin/Validation/Constraint/UserMailUnique.php2
-rw-r--r--core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraint.php2
-rw-r--r--core/modules/user/src/Plugin/Validation/Constraint/UserNameUnique.php2
34 files changed, 110 insertions, 43 deletions
diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraint.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraint.php
index 3bee330..022a345 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraint.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraint.php
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraint;
/**
* Checks if a value is a valid entity type.
*
- * @Plugin(
+ * @Constraint(
* id = "Bundle",
* label = @Translation("Bundle", context = "Validation"),
* type = { "entity", "entity_reference" }
diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraint.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraint.php
index 8a5f319..2a73455 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraint.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraint.php
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraint;
/**
* Validation constraint for the entity changed timestamp.
*
- * @Plugin(
+ * @Constraint(
* id = "EntityChanged",
* label = @Translation("Entity changed", context = "Validation"),
* type = {"entity"}
diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraint.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraint.php
index df25b6c..62194c4 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraint.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraint.php
@@ -2,7 +2,7 @@
/**
* @file
- * Contains \Drupal\Core\Entity\Constraint\EntityTypeConstraint.
+ * Contains \Drupal\Core\Entity\Plugin\Validation\Constraint\EntityTypeConstraint.
*/
namespace Drupal\Core\Entity\Plugin\Validation\Constraint;
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraint;
/**
* Checks if a value is a valid entity type.
*
- * @Plugin(
+ * @Constraint(
* id = "EntityType",
* label = @Translation("Entity type", context = "Validation"),
* type = { "entity", "entity_reference" }
diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraint.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraint.php
index d38827a..74bc0cc 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraint.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraint.php
@@ -14,7 +14,7 @@ use Symfony\Component\Validator\Constraint;
*
* Verifies that referenced entities are valid.
*
- * @Plugin(
+ * @Constraint(
* id = "ReferenceAccess",
* label = @Translation("Entity Reference reference access", context = "Validation")
* )
diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ValidReferenceConstraint.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ValidReferenceConstraint.php
index 2a7d6a9..d982193 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ValidReferenceConstraint.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ValidReferenceConstraint.php
@@ -14,7 +14,7 @@ use Symfony\Component\Validator\Constraint;
*
* Verifies that referenced entities are valid.
*
- * @Plugin(
+ * @Constraint(
* id = "ValidReference",
* label = @Translation("Entity Reference valid reference", context = "Validation")
* )
diff --git a/core/lib/Drupal/Core/Validation/Annotation/Constraint.php b/core/lib/Drupal/Core/Validation/Annotation/Constraint.php
new file mode 100644
index 0000000..7fce6e8
--- /dev/null
+++ b/core/lib/Drupal/Core/Validation/Annotation/Constraint.php
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Core\Validation\Annotation\Constraint.
+ */
+
+namespace Drupal\Core\Validation\Annotation;
+
+use Drupal\Component\Annotation\Plugin;
+
+/**
+ * Defines a validation constraint annotation object.
+ *
+ * Plugin Namespace: Plugin\Validation\Constraint
+ *
+ * For a working example, see
+ * \Drupal\Core\Validation\Plugin\Validation\Constraint\LengthConstraint
+ *
+ * @see \Drupal\Core\Validation\ConstraintManager
+ * @see \Symfony\Component\Validator\Constraint
+ * @see hook_validation_constraint_alter()
+ * @see plugin_api
+ *
+ * @Annotation
+ */
+class Constraint extends Plugin {
+
+ /**
+ * The constraint plugin ID.
+ *
+ * @var string
+ */
+ public $id;
+
+ /**
+ * The human-readable name of the constraint plugin.
+ *
+ * @ingroup plugin_translatable
+ *
+ * @var string|\Drupal\Core\Annotation\Translation
+ */
+ public $label;
+
+ /**
+ * An array of DataType plugin IDs for which this constraint applies. Valid
+ * values are any types registered by the typed data API, or an array of
+ * multiple type names. For supporting all types, FALSE may be specified. The
+ * key defaults to an empty array, which indicates no types are supported.
+ *
+ * @var string|string[]|false
+ *
+ * @see \Drupal\Core\TypedData\Annotation\DataType
+ */
+ public $type = [];
+
+}
diff --git a/core/lib/Drupal/Core/Validation/ConstraintManager.php b/core/lib/Drupal/Core/Validation/ConstraintManager.php
index 0ed8d97..da1f13a 100644
--- a/core/lib/Drupal/Core/Validation/ConstraintManager.php
+++ b/core/lib/Drupal/Core/Validation/ConstraintManager.php
@@ -26,10 +26,10 @@ use Drupal\Core\StringTranslation\TranslationWrapper;
* module would have to prefix any constraints with "Profile".
*
* Constraint plugins may specify data types to which support is limited via the
- * 'type' key of plugin definitions. Valid values are any types registered via
- * the typed data API, or an array of multiple type names. For supporting all
- * types FALSE may be specified. The key defaults to an empty array, i.e. no
- * types are supported.
+ * 'type' key of plugin definitions. See
+ * \Drupal\Core\Validation\Annotation\Constraint for details.
+ *
+ * @see \Drupal\Core\Validation\Annotation\Constraint
*/
class ConstraintManager extends DefaultPluginManager {
@@ -45,7 +45,7 @@ class ConstraintManager extends DefaultPluginManager {
* The module handler to invoke the alter hook with.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
- parent::__construct('Plugin/Validation/Constraint', $namespaces, $module_handler);
+ parent::__construct('Plugin/Validation/Constraint', $namespaces, $module_handler, NULL, 'Drupal\Core\Validation\Annotation\Constraint');
$this->discovery = new StaticDiscoveryDecorator($this->discovery, array($this, 'registerDefinitions'));
$this->alterInfo('validation_constraint');
$this->setCacheBackend($cache_backend, 'validation_constraint_plugins');
@@ -106,10 +106,7 @@ class ConstraintManager extends DefaultPluginManager {
*/
public function processDefinition(&$definition, $plugin_id) {
// Make sure 'type' is set and either an array or FALSE.
- if (!isset($definition['type'])) {
- $definition['type'] = array();
- }
- elseif ($definition['type'] !== FALSE && !is_array($definition['type'])) {
+ if ($definition['type'] !== FALSE && !is_array($definition['type'])) {
$definition['type'] = array($definition['type']);
}
}
diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraint.php
index 939fbab..b8381fd 100644
--- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraint.php
+++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraint.php
@@ -2,7 +2,7 @@
/**
* @file
- * Contains \Drupal\Core\Validation\Constraint\AllowedValuesConstraint.
+ * Contains \Drupal\Core\Validation\Plugin\Validation\Constraint\AllowedValuesConstraint.
*/
namespace Drupal\Core\Validation\Plugin\Validation\Constraint;
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraints\Choice;
/**
* Checks for the value being allowed.
*
- * @Plugin(
+ * @Constraint(
* id = "AllowedValues",
* label = @Translation("Allowed values", context = "Validation")
* )
diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php
index c9638ae..7dbbd40 100644
--- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php
+++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php
@@ -2,7 +2,7 @@
/**
* @file
- * Contains \Drupal\Core\Validation\Plugin\Validation\Constraint\CollectionConstraint.
+ * Contains \Drupal\Core\Validation\Plugin\Validation\Constraint\ComplexDataConstraint.
*/
namespace Drupal\Core\Validation\Plugin\Validation\Constraint;
@@ -14,7 +14,7 @@ use Symfony\Component\Validator\Constraint;
*
* Validates properties of complex data structures.
*
- * @Plugin(
+ * @Constraint(
* id = "ComplexData",
* label = @Translation("Complex data", context = "Validation")
* )
diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/CountConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/CountConstraint.php
index 77836a7..270d0d7 100644
--- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/CountConstraint.php
+++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/CountConstraint.php
@@ -14,7 +14,7 @@ use Symfony\Component\Validator\Constraints\Count;
*
* Overrides the symfony constraint to use Drupal-style replacement patterns.
*
- * @Plugin(
+ * @Constraint(
* id = "Count",
* label = @Translation("Count", context = "Validation"),
* type = { "list" }
diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php
index 905d1b6..48a6f99 100644
--- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php
+++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php
@@ -14,7 +14,7 @@ use Symfony\Component\Validator\Constraints\Email;
*
* Overrides the symfony constraint to use the strict setting.
*
- * @Plugin(
+ * @Constraint(
* id = "Email",
* label = @Translation("Email", context = "Validation")
* )
diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/IsNullConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/IsNullConstraint.php
index 401be63..714a0d2 100644
--- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/IsNullConstraint.php
+++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/IsNullConstraint.php
@@ -14,7 +14,7 @@ use Symfony\Component\Validator\Constraints\IsNull;
*
* Overrides the symfony constraint to handle empty Typed Data structures.
*
- * @Plugin(
+ * @Constraint(
* id = "Null",
* label = @Translation("Null", context = "Validation"),
* type = false
diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php
index f8b34b4..308afd1 100644
--- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php
+++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/LengthConstraint.php
@@ -16,7 +16,7 @@ use Symfony\Component\Validator\Constraints\Length;
*
* @todo: Move this below the TypedData core component.
*
- * @Plugin(
+ * @Constraint(
* id = "Length",
* label = @Translation("Length", context = "Validation"),
* type = { "string" }
diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/NotNullConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/NotNullConstraint.php
index 9b745ae..ec4569c 100644
--- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/NotNullConstraint.php
+++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/NotNullConstraint.php
@@ -14,7 +14,7 @@ use Symfony\Component\Validator\Constraints\NotNull;
*
* Overrides the symfony constraint to handle empty Typed Data structures.
*
- * @Plugin(
+ * @Constraint(
* id = "NotNull",
* label = @Translation("NotNull", context = "Validation"),
* type = false
diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraint.php
index 1d9ca3c..e8f1dd3 100644
--- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraint.php
+++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraint.php
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraint;
/**
* Supports validating all primitive types.
*
- * @Plugin(
+ * @Constraint(
* id = "PrimitiveType",
* label = @Translation("Primitive type", context = "Validation")
* )
diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RangeConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RangeConstraint.php
index c35b64f..298f59c 100644
--- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RangeConstraint.php
+++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RangeConstraint.php
@@ -16,7 +16,7 @@ use Symfony\Component\Validator\Constraints\Range;
*
* @todo: Move this below the TypedData core component.
*
- * @Plugin(
+ * @Constraint(
* id = "Range",
* label = @Translation("Range", context = "Validation"),
* type = { "integer", "float" }
diff --git a/core/modules/aggregator/src/Plugin/Validation/Constraint/FeedTitleConstraint.php b/core/modules/aggregator/src/Plugin/Validation/Constraint/FeedTitleConstraint.php
index 47d16ac..a8e71a2 100644
--- a/core/modules/aggregator/src/Plugin/Validation/Constraint/FeedTitleConstraint.php
+++ b/core/modules/aggregator/src/Plugin/Validation/Constraint/FeedTitleConstraint.php
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraint;
/**
* Supports validating feed titles.
*
- * @Plugin(
+ * @Constraint(
* id = "FeedTitle",
* label = @Translation("Feed title", context = "Validation")
* )
diff --git a/core/modules/aggregator/src/Plugin/Validation/Constraint/FeedUrlConstraint.php b/core/modules/aggregator/src/Plugin/Validation/Constraint/FeedUrlConstraint.php
index 0e2ce1d..cf41dee 100644
--- a/core/modules/aggregator/src/Plugin/Validation/Constraint/FeedUrlConstraint.php
+++ b/core/modules/aggregator/src/Plugin/Validation/Constraint/FeedUrlConstraint.php
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraint;
/**
* Supports validating feed URLs.
*
- * @Plugin(
+ * @Constraint(
* id = "FeedUrl",
* label = @Translation("Feed URL", context = "Validation")
* )
diff --git a/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraint.php b/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraint.php
index 4de6726..572192c 100644
--- a/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraint.php
+++ b/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraint.php
@@ -12,7 +12,7 @@ use Drupal\Core\Entity\Plugin\Validation\Constraint\CompositeConstraintBase;
/**
* Supports validating comment author names.
*
- * @Plugin(
+ * @Constraint(
* id = "CommentName",
* label = @Translation("Comment author name", context = "Validation"),
* type = "entity:comment"
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Validation/Constraint/TestFieldConstraint.php b/core/modules/field/tests/modules/field_test/src/Plugin/Validation/Constraint/TestFieldConstraint.php
index 61d7b20..fc57564 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Validation/Constraint/TestFieldConstraint.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Validation/Constraint/TestFieldConstraint.php
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraints\NotEqualTo;
/**
* Checks if a value is not equal.
*
- * @Plugin(
+ * @Constraint(
* id = "TestField",
* label = @Translation("Test Field", context = "Validation"),
* type = { "integer" }
diff --git a/core/modules/forum/src/Plugin/Validation/Constraint/ForumLeafConstraint.php b/core/modules/forum/src/Plugin/Validation/Constraint/ForumLeafConstraint.php
index 0f6312b..ad60d8e 100644
--- a/core/modules/forum/src/Plugin/Validation/Constraint/ForumLeafConstraint.php
+++ b/core/modules/forum/src/Plugin/Validation/Constraint/ForumLeafConstraint.php
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraint;
/**
* Checks that the node is assigned only a "leaf" term in the forum taxonomy.
*
- * @Plugin(
+ * @Constraint(
* id = "ForumLeaf",
* label = @Translation("Forum leaf", context = "Validation"),
* )
diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraint.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraint.php
index 31ba7b3..64984a6 100644
--- a/core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraint.php
+++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraint.php
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraint;
/**
* Defines an access validation constraint for links.
*
- * @Plugin(
+ * @Constraint(
* id = "LinkAccess",
* label = @Translation("Link URI can be accessed by the user.", context = "Validation"),
* )
diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraint.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraint.php
index 881c66e..aa98f06 100644
--- a/core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraint.php
+++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraint.php
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraint;
/**
* Defines a protocol validation constraint for links to external URLs.
*
- * @Plugin(
+ * @Constraint(
* id = "LinkExternalProtocols",
* label = @Translation("No dangerous external protocols", context = "Validation"),
* )
diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraint.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraint.php
index 3bcbb98..e97cd46 100644
--- a/core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraint.php
+++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraint.php
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraint;
/**
* Defines a protocol validation constraint for links to broken internal URLs.
*
- * @Plugin(
+ * @Constraint(
* id = "LinkNotExistingInternal",
* label = @Translation("No broken internal links", context = "Validation"),
* )
diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php
index 79a6e28..bc5d72b 100644
--- a/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php
+++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php
@@ -15,7 +15,7 @@ use Symfony\Component\Validator\ExecutionContextInterface;
/**
* Validation constraint for links receiving data allowed by its settings.
*
- * @Plugin(
+ * @Constraint(
* id = "LinkType",
* label = @Translation("Link data valid for link type.", context = "Validation"),
* )
diff --git a/core/modules/system/core.api.php b/core/modules/system/core.api.php
index 145d766..3501723 100644
--- a/core/modules/system/core.api.php
+++ b/core/modules/system/core.api.php
@@ -1968,6 +1968,19 @@ function hook_config_schema_info_alter(&$definitions) {
}
/**
+ * Alter validation constraint plugin definitions.
+ *
+ * @param array[] $definitions
+ * The array of validation constraint definitions, keyed by plugin ID.
+ *
+ * @see \Drupal\Core\Validation\ConstraintManager
+ * @see \Drupal\Core\Validation\Annotation\Constraint
+ */
+function hook_validation_constraint_alter(array &$definitions) {
+ $definitions['Null']['class'] = '\Drupal\mymodule\Validator\Constraints\MyClass';
+}
+
+/**
* @} End of "addtogroup hooks".
*/
diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/EntityTestCompositeConstraint.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/EntityTestCompositeConstraint.php
index c3b6ce8..79f6c02 100644
--- a/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/EntityTestCompositeConstraint.php
+++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/EntityTestCompositeConstraint.php
@@ -12,7 +12,7 @@ use Drupal\Core\Entity\Plugin\Validation\Constraint\CompositeConstraintBase;
/**
* Constraint with multiple fields.
*
- * @Plugin(
+ * @Constraint(
* id = "EntityTestComposite",
* label = @Translation("Constraint with multiple fields."),
* type = "entity"
diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/EntityTestEntityLevel.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/EntityTestEntityLevel.php
index ec647bd..093331e 100644
--- a/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/EntityTestEntityLevel.php
+++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/EntityTestEntityLevel.php
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraint;
/**
* Constraint on entity entity level.
*
- * @Plugin(
+ * @Constraint(
* id = "EntityTestEntityLevel",
* label = @Translation("Constraint on the entity level."),
* type = "entity"
diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/FieldWidgetConstraint.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/FieldWidgetConstraint.php
index ea2f448..4e5cede 100644
--- a/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/FieldWidgetConstraint.php
+++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/FieldWidgetConstraint.php
@@ -11,7 +11,7 @@ use Symfony\Component\Validator\Constraint;
/**
* Supports validating widget constraints.
*
- * @Plugin(
+ * @Constraint(
* id = "FieldWidgetConstraint",
* label = @Translation("Field widget constraint.")
* )
diff --git a/core/modules/user/src/Plugin/Validation/Constraint/ProtectedUserFieldConstraint.php b/core/modules/user/src/Plugin/Validation/Constraint/ProtectedUserFieldConstraint.php
index fd3ca3d..2d2e837 100644
--- a/core/modules/user/src/Plugin/Validation/Constraint/ProtectedUserFieldConstraint.php
+++ b/core/modules/user/src/Plugin/Validation/Constraint/ProtectedUserFieldConstraint.php
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraint;
/**
* Checks if the plain text password is provided for editing a protected field.
*
- * @Plugin(
+ * @Constraint(
* id = "ProtectedUserField",
* label = @Translation("Password required for protected field change", context = "Validation")
* )
diff --git a/core/modules/user/src/Plugin/Validation/Constraint/UserMailRequired.php b/core/modules/user/src/Plugin/Validation/Constraint/UserMailRequired.php
index f463c3a..0a6b8e9 100644
--- a/core/modules/user/src/Plugin/Validation/Constraint/UserMailRequired.php
+++ b/core/modules/user/src/Plugin/Validation/Constraint/UserMailRequired.php
@@ -19,7 +19,7 @@ use Symfony\Component\Validator\ExecutionContextInterface;
* and the user performing the edit has 'administer users' permission.
* This allows users without email address to be edited and deleted.
*
- * @Plugin(
+ * @Constraint(
* id = "UserMailRequired",
* label = @Translation("User email required", context = "Validation")
* )
diff --git a/core/modules/user/src/Plugin/Validation/Constraint/UserMailUnique.php b/core/modules/user/src/Plugin/Validation/Constraint/UserMailUnique.php
index e541518..210e00c 100644
--- a/core/modules/user/src/Plugin/Validation/Constraint/UserMailUnique.php
+++ b/core/modules/user/src/Plugin/Validation/Constraint/UserMailUnique.php
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraint;
/**
* Checks if a user's email address is unique on the site.
*
- * @Plugin(
+ * @Constraint(
* id = "UserMailUnique",
* label = @Translation("User email unique", context = "Validation")
* )
diff --git a/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraint.php b/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraint.php
index 381d3cf..70c0bc7 100644
--- a/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraint.php
+++ b/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraint.php
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraint;
/**
* Checks if a value is a valid user name.
*
- * @Plugin(
+ * @Constraint(
* id = "UserName",
* label = @Translation("User name", context = "Validation"),
* )
diff --git a/core/modules/user/src/Plugin/Validation/Constraint/UserNameUnique.php b/core/modules/user/src/Plugin/Validation/Constraint/UserNameUnique.php
index 0a65d32..286d340 100644
--- a/core/modules/user/src/Plugin/Validation/Constraint/UserNameUnique.php
+++ b/core/modules/user/src/Plugin/Validation/Constraint/UserNameUnique.php
@@ -12,7 +12,7 @@ use Symfony\Component\Validator\Constraint;
/**
* Checks if a user name is unique on the site.
*
- * @Plugin(
+ * @Constraint(
* id = "UserNameUnique",
* label = @Translation("User name unique", context = "Validation"),
* )