public function GalleryMediaBundleConstraintValidator::validate in D7 Media 8
File
- src/
Plugin/ Validation/ Constraint/ GalleryMediaBundleConstraintValidator.php, line 16
Class
- GalleryMediaBundleConstraintValidator
- Validates the GalleryMediaBundle constraint.
Namespace
Drupal\media\Plugin\Validation\ConstraintCode
public function validate($value, Constraint $constraint) {
if (!isset($value)) {
return;
}
if ($value
->hasField($constraint->sourceFieldName)) {
$slideshowItems = $value
->get($constraint->sourceFieldName);
foreach ($slideshowItems as $item) {
if ($item->entity
->getType()
->getPluginId() == "slideshow") {
$this->context
->addViolation($constraint->message);
}
}
}
}