You are here

MediaItemsCountConstraintValidator.php in Varbase Media 9.0.x

File

src/Plugin/Validation/Constraint/MediaItemsCountConstraintValidator.php
View source
<?php

namespace Drupal\varbase_media\Plugin\Validation\Constraint;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;

/**
 * Validates the MediaItemsCount constraint.
 */
class MediaItemsCountConstraintValidator extends ConstraintValidator {

  /**
   * {@inheritdoc}
   */
  public function validate($value, Constraint $constraint) {
    if (!isset($value)) {
      return;
    }
    if ($value
      ->get($constraint->sourceFieldName)
      ->isEmpty()) {
      $this->context
        ->addViolation($constraint->message);
    }
  }

}

Classes

Namesort descending Description
MediaItemsCountConstraintValidator Validates the MediaItemsCount constraint.