diff --git a/core/lib/Drupal/Core/Validation/Annotation/Constraint.php b/core/lib/Drupal/Core/Validation/Annotation/Constraint.php index a5b022e..85c4344 100644 --- a/core/lib/Drupal/Core/Validation/Annotation/Constraint.php +++ b/core/lib/Drupal/Core/Validation/Annotation/Constraint.php @@ -13,7 +13,6 @@ * Defines a validation constraint annotation object. * * @see \Drupal\Core\Validation\ConstraintManager - * @see hook_validation_constraint_info_alter() * * @Annotation */ @@ -22,6 +21,9 @@ class Constraint extends Plugin { /** * The constraint plugin ID. * + * The plugin ID usually resembles the class name without the "Constraint" + * suffix. + * * @var string */ public $id; @@ -41,10 +43,10 @@ class Constraint extends Plugin { * type names. For supporting all types, FALSE may be specified. The key * defaults to an empty array, i.e. no types are supported. * - * @var mixed + * @var string|string[]|false * * @see \Drupal\Core\TypedData\Annotation\DataType */ - public $types; + public $type = array(); -} \ No newline at end of file +} diff --git a/core/lib/Drupal/Core/Validation/ConstraintManager.php b/core/lib/Drupal/Core/Validation/ConstraintManager.php index 4b207fd..b6b0d16 100644 --- a/core/lib/Drupal/Core/Validation/ConstraintManager.php +++ b/core/lib/Drupal/Core/Validation/ConstraintManager.php @@ -26,10 +26,10 @@ * 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, 'Drupal\Core\Validation\Annotation\Constraint'); + 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'); @@ -111,10 +111,7 @@ public function registerDefinitions() { */ 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/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 @@ * * Overrides the symfony constraint to use the strict setting. * - * @Plugin( + * @Constraint( * id = "Email", * label = @Translation("Email", context = "Validation") * ) 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 @@ /** * Supports validating feed titles. * - * @Plugin( + * @Constraint( * id = "FeedTitle", * label = @Translation("Feed title", 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 575a393..7b66245 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 @@ /** * Supports validating comment author names. * - * @Plugin( + * @Constraint( * id = "CommentName", * label = @Translation("Comment author name", 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 89ff6da..891f386 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 @@ /** * Validation constraint for links receiving data allowed by its settings. * - * @Plugin( + * @Constraint( * id = "LinkType", * label = @Translation("Link data valid for link type.", context = "Validation"), * )