/** * The given $value is valid if it is an \TYPO3\Media\Domain\Model\ImageInterface of the * configured orientation (square, portrait and/or landscape) * Note: a value of NULL or empty string ('') is considered valid * * @param \TYPO3\Media\Domain\Model\ImageInterface $image The image that should be validated * @return void * @api */ protected function isValid($image) { $this->validateOptions(); if (!$image instanceof \TYPO3\Media\Domain\Model\ImageInterface) { $this->addError('The given value was not an Image instance.', 1328028604); return; } if (!in_array($image->getOrientation(), $this->options['allowedOrientations'])) { if (count($this->options['allowedOrientations']) === 1) { reset($this->options['allowedOrientations']); $allowedOrientation = current($this->options['allowedOrientations']); $this->addError('The image orientation must be "%s".', 1328029406, array($allowedOrientation)); } else { $this->addError('The image orientation "%s" is not allowed.', 1328029362, array($image->getOrientation())); } } }