eZ\Publish\Core\FieldType\BinaryBase\Type::checkValueStructure PHP Method

checkValueStructure() protected method

Throws an exception if value structure is not of expected format.
protected checkValueStructure ( Value $value )
$value eZ\Publish\Core\FieldType\Value
    protected function checkValueStructure(BaseValue $value)
    {
        // Input file URI, if set needs to point to existing file
        if (isset($value->inputUri)) {
            if (!file_exists($value->inputUri)) {
                throw new InvalidArgumentValue('$value->inputUri', $value->inputUri, get_class($this));
            }
        } elseif (!isset($value->id)) {
            throw new InvalidArgumentValue('$value->id', $value->id, get_class($this));
        }
        // Required parameter $fileName
        if (!isset($value->fileName) || !is_string($value->fileName)) {
            throw new InvalidArgumentValue('$value->fileName', $value->fileName, get_class($this));
        }
        // Optional parameter $fileSize
        if (isset($value->fileSize) && !is_int($value->fileSize)) {
            throw new InvalidArgumentValue('$value->fileSize', $value->fileSize, get_class($this));
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Throws an exception if value structure is not of expected format.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the value does not match the expected structure.
  *
  * @param \eZ\Publish\Core\FieldType\Media\Value $value
  */
 protected function checkValueStructure(BaseValue $value)
 {
     parent::checkValueStructure($value);
     if (!is_bool($value->hasController)) {
         throw new InvalidArgumentType('$value->hasController', 'bool', $value->hasController);
     }
     if (!is_bool($value->autoplay)) {
         throw new InvalidArgumentType('$value->autoplay', 'bool', $value->autoplay);
     }
     if (!is_bool($value->loop)) {
         throw new InvalidArgumentType('$value->loop', 'bool', $value->loop);
     }
     if (!is_int($value->height)) {
         throw new InvalidArgumentType('$value->height', 'int', $value->height);
     }
     if (!is_int($value->width)) {
         throw new InvalidArgumentType('$value->width', 'int', $value->width);
     }
 }