/** * Creates a new Visibility criterion. * * @param int $value Visibility: self::VISIBLE, self::HIDDEN * * @throws \InvalidArgumentException */ public function __construct($value) { if ($value !== self::VISIBLE && $value !== self::HIDDEN) { throw new InvalidArgumentException("Invalid visibility value {$value}"); } parent::__construct(null, null, $value); }
/** * Creates a new DateMetadata criterion on $metadata * * @throws \InvalidArgumentException If target is unknown * * @param string $target One of DateMetadata::CREATED or DateMetadata::MODIFIED * @param string $operator One of the Operator constants * @param mixed $value The match value, either as an array of as a single value, depending on the operator */ public function __construct($target, $operator, $value) { if ($target != self::MODIFIED && $target != self::CREATED) { throw new InvalidArgumentException("Unknown DateMetadata {$target}"); } parent::__construct($target, $operator, $value); }
/** * Creates a new LanguageCode criterion. * * @param string|string[] $value One or more language codes that must be matched * @param bool $matchAlwaysAvailable Denotes if always-available Content is to be matched regardless * of language codes, this is the default behaviour * * @throws \InvalidArgumentException if non string value is given * @throws \InvalidArgumentException if the value type doesn't match the operator */ public function __construct($value, $matchAlwaysAvailable = true) { if (!is_bool($matchAlwaysAvailable)) { throw new InvalidArgumentType('matchAlwaysAvailable', 'boolean', $matchAlwaysAvailable); } $this->matchAlwaysAvailable = $matchAlwaysAvailable; parent::__construct(null, null, $value); }
/** * Creates a new SubTree criterion. * * @param string|string[] $value an array of subtree path strings, eg: /1/2/ * * @throws InvalidArgumentException if a non path string is given * @throws InvalidArgumentException if the value type doesn't match the operator */ public function __construct($value) { foreach ((array) $value as $pathString) { if (preg_match('/^(\\/\\w+)+\\/$/', $pathString) !== 1) { throw new InvalidArgumentException("value '{$pathString}' must follow the pathString format, eg /1/2/"); } } parent::__construct(null, null, $value); }
/** * Creates a new UserMetadata criterion on $metadata. * * @throws \InvalidArgumentException If target is unknown * * @param string $target One of UserMetadata::OWNER, UserMetadata::GROUP or UserMetadata::MODIFIED * @param string $operator One of the Operator constants * @param mixed $value The match value, either as an array of as a single value, depending on the operator */ public function __construct($target, $operator, $value) { switch ($target) { case self::OWNER: case self::GROUP: case self::MODIFIER: parent::__construct($target, $operator, $value); return; } throw new InvalidArgumentException("Unknown UserMetadata {$target}"); }
public function __construct($value, array $properties = array()) { parent::__construct(null, Operator::LIKE, $value); // Assign additional properties, ugly but with the existing constructor // API the only sensible way, I guess. foreach ($properties as $name => $value) { if (!isset($this->{$name})) { throw new \InvalidArgumentException("Unknown property {$name}."); } $this->{$name} = $value; } }
/** * Creates a new Status criterion * * @param string|string[] $value Status: self::STATUS_ARCHIVED, self::STATUS_DRAFT, self::STATUS_PUBLISHED * * @throws \InvalidArgumentException */ public function __construct($value) { foreach ((array) $value as $statusValue) { switch ($statusValue) { case self::STATUS_ARCHIVED: case self::STATUS_DRAFT: case self::STATUS_PUBLISHED: continue; default: throw new InvalidArgumentException("Invalid status {$statusValue}"); } } parent::__construct(null, null, $value); }
/** * Creates a new remoteId criterion. * * @param int|int[] $value One or more remoteId that must be matched * * @throws \InvalidArgumentException if a non numeric id is given * @throws \InvalidArgumentException if the value type doesn't match the operator */ public function __construct($value) { parent::__construct(null, null, $value); }
/** * Creates a new more like this criterion. * * @param int $type the type (one of CONTENT,TEXT,URL) * @param mixed $value the value depending on the type * * @throws \InvalidArgumentException if the value type doesn't match the expected type */ public function __construct($type, $value) { $this->type = $type; parent::__construct(null, null, $value); }
/** * Creates a new TagKeyword criterion. * * @param string $operator * @param string|string[] $value One or more tag keywords that must be matched * @param string $target Field definition identifier to use * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion\Value $valueData * * @throws \InvalidArgumentException if a non string parameter is given * @throws \InvalidArgumentException if the value type doesn't match the operator */ public function __construct($operator, $value, $target = null, Value $valueData = null) { parent::__construct($target, $operator, $value, $valueData); }
/** * Creates a new LocationPriority criterion * * @param string $operator One of the Operator constants * @param mixed $value The match value, either as an array of as a single value, depending on the operator * * @deprecated Since 5.3, use Location search instead */ public function __construct($operator, $value) { parent::__construct(null, $operator, $value); }
/** * @param string $target FieldDefinition identifier * @param string $operator One of the supported Operator constants * @param float|float[] $distance The match value in kilometers, either as an array * or as a single value, depending on the operator * @param float $latitude Latitude of the location that distance is calculated from * @param float $longitude Longitude of the location that distance is calculated from */ public function __construct($target, $operator, $distance, $latitude, $longitude) { $distanceStart = new MapLocationValue($latitude, $longitude); parent::__construct($target, $operator, $distance, $distanceStart); }
/** * Creates a new TagId criterion. * * @param int|int[] $value One or more tag IDs that must be matched * @param string $target Field definition identifier to use * * @throws \InvalidArgumentException if a non numeric id is given * @throws \InvalidArgumentException if the value type doesn't match the operator */ public function __construct($value, $target = null) { parent::__construct($target, null, $value); }