class GalleryMediaBundleConstraintValidator in D7 Media 8
Validates the GalleryMediaBundle constraint.
Hierarchy
- class \Drupal\media\Plugin\Validation\Constraint\GalleryMediaBundleConstraintValidator extends \Symfony\Component\Validator\ConstraintValidator
Expanded class hierarchy of GalleryMediaBundleConstraintValidator
File
- src/
Plugin/ Validation/ Constraint/ GalleryMediaBundleConstraintValidator.php, line 11
Namespace
Drupal\media\Plugin\Validation\ConstraintView source
class GalleryMediaBundleConstraintValidator extends ConstraintValidator {
/**
* {@inheritdoc}
*/
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);
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
GalleryMediaBundleConstraintValidator:: |
public | function | Checks if the passed value is valid. |