Further modules included.
[yaffs-website] / web / modules / contrib / media / src / Plugin / Validation / Constraint / GalleryMediaBundleConstraintValidator.php
1 <?php
2
3 namespace Drupal\media\Plugin\Validation\Constraint;
4
5 use Symfony\Component\Validator\Constraint;
6 use Symfony\Component\Validator\ConstraintValidator;
7
8 /**
9  * Validates the GalleryMediaBundle constraint.
10  */
11 class GalleryMediaBundleConstraintValidator extends ConstraintValidator {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function validate($value, Constraint $constraint) {
17     if (!isset($value)) {
18       return;
19     }
20     if ($value->hasField($constraint->sourceFieldName)) {
21       $slideshowItems = $value->get($constraint->sourceFieldName);
22       foreach ($slideshowItems as $item) {
23         if ($item->entity->getType()->getPluginId() == "slideshow") {
24           $this->context->addViolation($constraint->message);
25         }
26       }
27     }
28   }
29
30 }