class BundleConstraintValidator
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraintValidator.php \Drupal\Core\Entity\Plugin\Validation\Constraint\BundleConstraintValidator
- 8.9.x core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraintValidator.php \Drupal\Core\Entity\Plugin\Validation\Constraint\BundleConstraintValidator
- 11.x core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraintValidator.php \Drupal\Core\Entity\Plugin\Validation\Constraint\BundleConstraintValidator
Validates the Bundle constraint.
Hierarchy
- class \Drupal\Core\Entity\Plugin\Validation\Constraint\BundleConstraintValidator extends \Symfony\Component\Validator\ConstraintValidator
Expanded class hierarchy of BundleConstraintValidator
File
-
core/
lib/ Drupal/ Core/ Entity/ Plugin/ Validation/ Constraint/ BundleConstraintValidator.php, line 11
Namespace
Drupal\Core\Entity\Plugin\Validation\ConstraintView source
class BundleConstraintValidator extends ConstraintValidator {
/**
* {@inheritdoc}
*
* phpcs:ignore Drupal.Commenting.FunctionComment.VoidReturn
* @return void
*/
public function validate($entity, Constraint $constraint) {
if (!isset($entity)) {
return;
}
if (!in_array($entity->bundle(), $constraint->getBundleOption())) {
$this->context
->addViolation($constraint->message, [
'%bundle' => implode(', ', $constraint->getBundleOption()),
]);
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
BundleConstraintValidator::validate | public | function | phpcs:ignore Drupal.Commenting.FunctionComment.VoidReturn |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.