class FilterOperation extends AbstractOperation (View source)

Filter operation, limiting the set of objects. The filter expression is expected as string argument and used to reduce the context to matching elements by checking each value against the filter.

A filter expression is written in Fizzle, a grammar inspired by CSS selectors. It has the form "[" [<value>] <operator> <operand> "]" and supports the following operators:

=~ Strict equality of case-insensitive value and operand

Strict equality of value and operand !=~ Strict inequality of case-insensitive value and operand != Strict inequality of value and operand < Value is less than operand <= Value is less than or equal to operand

Value is greater than operand

Value is greater than or equal to operand $=~ Value ends with operand (string-based) or case-insensitive value's last element is equal to operand (array-based) $= Value ends with operand (string-based) or value's last element is equal to operand (array-based) ^=~ Value starts with operand (string-based) or case-insensitive value's first element is equal to operand (array-based) ^= Value starts with operand (string-based) or value's first element is equal to operand (array-based) =~ Value contains operand (string-based) or case-insensitive value contains an element that is equal to operand (array based) = Value contains operand (string-based) or value contains an element that is equal to operand (array based) instanceof Checks if the value is an instance of the operand !instanceof Checks if the value is not an instance of the operand

For the latter the behavior is as follows: if the operand is one of the strings object, array, int(eger), float, double, bool(ean) or string the value is checked for being of the specified type. For any other strings the value is used as classname with the PHP instanceof operation to check if the value matches.

Properties

static protected string $shortName {@inheritdoc}
static protected int $priority

The priority of operations. higher numbers override lower ones.

from  AbstractOperation
static protected bool $final

If true, the operation is final, i.e. directly executed.

from  AbstractOperation
protected PersistenceManagerInterface $persistenceManager

Methods

static int
getPriority()

No description

static bool
isFinal()

No description

static string
getShortName()

No description

bool
canEvaluate(array $context)

This method is called to determine whether the operation can work with the $context objects. It can be implemented to implement runtime conditions.

mixed
evaluate(FlowQuery $flowQuery, array $arguments)

Evaluate the operation on the objects inside $flowQuery->getContext(), taking the $arguments into account.

bool
matchesFilterGroup(object $element, array $parsedFilter)

Evaluate Filter Group. An element matches the filter group if it matches at least one part of the filter group.

bool
matchesFilter(object $element, string $filter)

Match a single filter, i.e. [foo]. It matches only if all filter parts match.

bool
matchesPropertyNameFilter(object $element, string $propertyNameFilter)

For generic objects, we do not support property name filters.

bool
matchesAttributeFilter(mixed $element, array $attributeFilter)

Match a single attribute filter

bool
matchesIdentifierFilter(object $element, string $identifier)

Filter the object by its identifier (UUID)

mixed
getPropertyPath(object $element, string $propertyPath)

Evaluate a property path. This is outsourced to a single method to make overriding this functionality easy.

bool
evaluateOperator(mixed $value, string $operator, mixed $operand)

Evaluate an operator

bool
operandIsSimpleType(string $type)

No description

bool
handleSimpleTypeOperand(string $operand, mixed $value)

No description

Details

static int getPriority()

No description

Return Value

int

the priority of the operation

static bool isFinal()

No description

Return Value

bool

true if the operation is final, false otherwise

static string getShortName()

No description

Return Value

string

the short name of the operation

Exceptions

FlowQueryException

bool canEvaluate(array $context)

This method is called to determine whether the operation can work with the $context objects. It can be implemented to implement runtime conditions.

Parameters

array $context

(or array-like object) $context onto which this operation should be applied

Return Value

bool

true if the operation can be applied onto the $context, false otherwise

mixed evaluate(FlowQuery $flowQuery, array $arguments)

Evaluate the operation on the objects inside $flowQuery->getContext(), taking the $arguments into account.

The resulting operation results should be stored using $flowQuery->setContext().

If the operation is final, evaluate should directly return the operation result.

Parameters

FlowQuery $flowQuery

the FlowQuery object

array $arguments

the arguments for this operation

Return Value

mixed

if the operation is final, the return value

protected bool matchesFilterGroup(object $element, array $parsedFilter)

Evaluate Filter Group. An element matches the filter group if it matches at least one part of the filter group.

Filter Group is something like "[foo], [bar]"

Parameters

object $element
array $parsedFilter

Return Value

bool

true if $element matches filter group, false otherwise

protected bool matchesFilter(object $element, string $filter)

Match a single filter, i.e. [foo]. It matches only if all filter parts match.

Parameters

object $element
string $filter

Return Value

bool

true if $element matches filter, false otherwise

protected bool matchesPropertyNameFilter(object $element, string $propertyNameFilter)

For generic objects, we do not support property name filters.

Parameters

object $element
string $propertyNameFilter

Return Value

bool

Exceptions

FizzleException

protected bool matchesAttributeFilter(mixed $element, array $attributeFilter)

Match a single attribute filter

Parameters

mixed $element
array $attributeFilter

Return Value

bool

protected bool matchesIdentifierFilter(object $element, string $identifier)

Filter the object by its identifier (UUID)

Parameters

object $element
string $identifier

Return Value

bool

protected mixed getPropertyPath(object $element, string $propertyPath)

Evaluate a property path. This is outsourced to a single method to make overriding this functionality easy.

Parameters

object $element
string $propertyPath

Return Value

mixed

protected bool evaluateOperator(mixed $value, string $operator, mixed $operand)

Evaluate an operator

Parameters

mixed $value
string $operator
mixed $operand

Return Value

bool

protected bool operandIsSimpleType(string $type)

No description

Parameters

string $type

Return Value

bool

true if operand is a simple type (object, array, string, ...); i.e. everything which is NOT a class name

protected bool handleSimpleTypeOperand(string $operand, mixed $value)

No description

Parameters

string $operand
mixed $value

Return Value

bool

true if $value is of type $operand; false otherwise