コード例 #1
0
ファイル: ImageTypeValidator.php プロジェクト: netlogix/media
 /**
  * The given $value is valid if it is an \TYPO3\Media\Domain\Model\ImageInterface of the
  * configured type (one of the image/* IANA media subtypes)
  *
  * Note: a value of NULL or empty string ('') is considered valid
  *
  * @param ImageInterface $image The image that should be validated
  * @return void
  * @api
  */
 protected function isValid($image)
 {
     $this->validateOptions();
     if (!$image instanceof Image) {
         $this->addError('The given value was not an Image instance.', 1327947256);
         return;
     }
     $allowedImageTypes = $this->options['allowedTypes'];
     array_walk($allowedImageTypes, function (&$value) {
         $value = 'image/' . $value;
     });
     if (!in_array($image->getMediaType(), $allowedImageTypes)) {
         $this->addError('The media type "%s" is not allowed for this image.', 1327947647, array($image->getMediaType()));
     }
 }