You are here

class GalleryMediaBundleConstraintValidator in D7 Media 8

Validates the GalleryMediaBundle constraint.

Hierarchy

Expanded class hierarchy of GalleryMediaBundleConstraintValidator

File

src/Plugin/Validation/Constraint/GalleryMediaBundleConstraintValidator.php, line 11

Namespace

Drupal\media\Plugin\Validation\Constraint
View 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

Namesort descending Modifiers Type Description Overrides
GalleryMediaBundleConstraintValidator::validate public function Checks if the passed value is valid.