Interface

eZ\Publish\SPI\Limitation\Type

interface Type

This interface represent the Limitation Type.

A Limitation is a lot like a Symfony voter, telling the permission system if user has access or not. It consists of a Limitation Value which is persisted, and this Limitation Type which contains the business logic for evaluate ("vote"), as well as accepting and validating the Value object and to generate criteria for content/location searches.

Constants

ACCESS_GRANTED

Constants for return value of {see evaluate()}.

Currently ACCESS_ABSTAIN must mean that evaluate does not support the provided $object or $targets, this is currently only supported by role limitations as policy limitations should not allow this.

Note: In future version constant values might change to 1, 0 and -1 as used in Symfony.

ACCESS_ABSTAIN

ACCESS_DENIED

VALUE_SCHEMA_LOCATION_ID

Constants for valueSchema() return values.

Used in cases where a certain value is accepted but the options are to many to return as a hash of options. GUI should typically present option to browse content tree to select limitation value(s).

VALUE_SCHEMA_LOCATION_PATH

Methods

acceptValue(Limitation $limitationValue)

Accepts a Limitation value and checks for structural validity.

ValidationError[] validate(Limitation $limitationValue)

Makes sure LimitationValue->limitationValues is valid according to valueSchema().

Limitation buildValue(array $limitationValues)

Create the Limitation Value.

bool|null evaluate(Limitation $value, UserReference $currentUser, ValueObject $object, array $targets = null)

Evaluate ("Vote") against a main value object and targets for the context.

CriterionInterface|LogicalOperator getCriterion(Limitation $value, UserReference $currentUser)

Returns Criterion for use in find() query.

mixed[]|int valueSchema()

Returns info on valid $limitationValues.

Details

at line 57
public acceptValue(Limitation $limitationValue)

Accepts a Limitation value and checks for structural validity.

Makes sure LimitationValue object and ->limitationValues is of correct type.

Parameters

Limitation $limitationValue

Exceptions

InvalidArgumentException If the value does not match the expected type/structure

at line 68
public ValidationError[] validate(Limitation $limitationValue)

Makes sure LimitationValue->limitationValues is valid according to valueSchema().

Make sure {@link acceptValue()} is checked first!

Parameters

Limitation $limitationValue

Return Value

ValidationError[]

at line 80
public Limitation buildValue(array $limitationValues)

Create the Limitation Value.

The is the method to create values as Limitation type needs value knowledge anyway in acceptValue, the reverse relation is provided by means of identifier lookup (Value has identifier, and so does RoleService).

Parameters

array $limitationValues

Return Value

Limitation

at line 99
public bool|null evaluate(Limitation $value, UserReference $currentUser, ValueObject $object, array $targets = null)

Evaluate ("Vote") against a main value object and targets for the context.

Parameters

Limitation $value
UserReference $currentUser
ValueObject $object
array $targets An array of location, parent or "assignment" objects, if null: none where provided by caller

Return Value

bool|null Returns one of ACCESS_* constants

Exceptions

InvalidArgumentException If any of the arguments are invalid Example: If LimitationValue is instance of ContentTypeLimitationValue, and Type is SectionLimitationType. However if $object or $targets is unsupported by ROLE limitation, ACCESS_ABSTAIN should be returned!
BadStateException If value of the LimitationValue is unsupported Example if OwnerLimitationValue->limitationValues[0] is not one of: [ 1, 2 ]

at line 112
public CriterionInterface|LogicalOperator getCriterion(Limitation $value, UserReference $currentUser)

Returns Criterion for use in find() query.

Parameters

Limitation $value
UserReference $currentUser

Return Value

CriterionInterface|LogicalOperator

Exceptions

NotImplementedException If the limitation does not support being used as a Criterion.

at line 121
public mixed[]|int valueSchema()

Returns info on valid $limitationValues.

Return Value

mixed[]|int In case of array, a hash with key as valid limitations value and value as human readable name of that option, in case of int on of VALUESCHEMA* constants. Note: The hash might be an instance of Traversable, and not a native php array.