FilterOperation
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
This method is called to determine whether the operation can work with the $context objects. It can be implemented to implement runtime conditions.
Evaluate Filter Group. An element matches the filter group if it matches at least one part of the filter group.
Match a single filter, i.e. [foo]. It matches only if all filter parts match.
For generic objects, we do not support property name filters.
Match a single attribute filter
Filter the object by its identifier (UUID)
Evaluate a property path. This is outsourced to a single method to make overriding this functionality easy.
Evaluate an operator
No description
No description
Details
static int
getPriority()
No description
static bool
isFinal()
No description
static string
getShortName()
No description
bool
canEvaluate($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|null
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.
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]"
protected bool
matchesFilter(object $element, string $filter)
Match a single filter, i.e. [foo]. It matches only if all filter parts match.
protected bool
matchesPropertyNameFilter(object $element, string $propertyNameFilter)
For generic objects, we do not support property name filters.
protected bool
matchesAttributeFilter(mixed $element, array $attributeFilter)
Match a single attribute filter
protected bool
matchesIdentifierFilter(object $element, string $identifier)
Filter the object by its identifier (UUID)
protected mixed
getPropertyPath(object $element, string $propertyPath)
Evaluate a property path. This is outsourced to a single method to make overriding this functionality easy.
protected bool
evaluateOperator(mixed $value, string $operator, mixed $operand)
Evaluate an operator
protected bool
operandIsSimpleType(string $type)
No description
protected bool
handleSimpleTypeOperand(string $operand, string $value)
No description