Oihana PHP Arango

HasHierarchicalFilter uses \oihana\traits\ContainerTrait, \Psr\Log\LoggerAwareTrait

Table of Contents

Methods

prepareHierarchicalFilter()  : string|null
Prepare a hierarchical filter from the declarative `AQL::FILTERS` configuration.
buildArrayTraversal()  : string|null
Build an array expansion traversal (`contactPoint[*].email`).
buildDocumentTraversal()  : string|null
buildEdgeTraversal()  : string|null
Build edge traversal
buildFilterRecursive()  : string|null
Build filter condition recursively through path segments.
buildInnerListCondition()  : string
The condition on a list named last inside another list (`stops[*].scans[*]`) : a `match` on its elements, or how many of them there are.
buildJoinTraversal()  : string|null
Build join traversal
buildLeafCondition()  : string|null
Build the leaf condition by delegating to the flat filter helpers.
innerListFilters()  : array<string|int, mixed>
The sub-filters the last list of a path declares, walked from the sub-filters of the list the path starts under — empty when a level declares none.
refuseUndeclaredArrayLeaf()  : void
Refuses an element sub-field the list does not declare, following the path when it goes on under a declared object (`offers[*].seller.id`).

Methods

prepareHierarchicalFilter()

Prepare a hierarchical filter from the declarative `AQL::FILTERS` configuration.

protected prepareHierarchicalFilter(array<string|int, mixed> $init, array<string|int, mixed> &$binds[, string $docRef = AQL::DOC ][, array<string|int, mixed> $auth = [] ]) : string|null

Entry point of the dotted-key grammar: the caller's key is split on . and each segment is walked against the configuration of the level it belongs to, crossing nested objects, array expansions, edges and joins until a leaf is reached.

// ?filter={ "key":"address.city" , "val":"Paris" }
// -> doc.address.city == @value
Parameters
$init : array<string|int, mixed>

The filter parameters (key, val, op, alt, quant, …).

$binds : array<string|int, mixed>

The bind variables, populated by reference.

$docRef : string = AQL::DOC

The document reference the condition is written against.

$auth : array<string|int, mixed> = []

The caller's permission context, consulted by the leaf gate so a locked field is neutralised to false rather than dropped.

Tags
throws
BindException
ConstantException
ContainerExceptionInterface
DependencyException
NotFoundException
NotFoundExceptionInterface
ReflectionException
RequestValidationException

When the request itself is refused (unknown operator, unusable quantifier).

RuntimeException

When the configuration names a relation or a model that cannot be resolved.

UnsupportedOperationException
ValidationException
Return values
string|null —

The AQL condition, or null when the key is empty or the path is not declared filterable.

buildArrayTraversal()

Build an array expansion traversal (`contactPoint[*].email`).

private buildArrayTraversal(array<string|int, mixed> $remainingSegments, FilterPath $segmentInfo, array<string|int, mixed> $init, array<string|int, mixed> &$binds, string $docRef[, array<string|int, mixed> $auth = [] ][, array<string|int, mixed>|null $currentFields = null ][, array<string|int, mixed> $fieldPath = [] ]) : string|null

The remaining segments are folded back into a single flat key so the array filter can emit the inline expansion in one predicate.

Parameters
$remainingSegments : array<string|int, mixed>

The segments below the array, addressing the element sub-field.

$segmentInfo : FilterPath

The parsed array segment.

$init : array<string|int, mixed>

The original filter parameters.

$binds : array<string|int, mixed>

The bind variables, populated by reference.

$docRef : string

The document reference holding the array.

$auth : array<string|int, mixed> = []

The caller's permission context.

$currentFields : array<string|int, mixed>|null = null

The projection of the model holding the array.

$fieldPath : array<string|int, mixed> = []

The path relative to $currentFields.

Tags
throws
BindException
RequestValidationException

When the request itself is refused.

UnsupportedOperationException
ValidationException
Return values
string|null —

The AQL condition, or false when the sub-field is refused by the permission gate.

buildDocumentTraversal()

private buildDocumentTraversal(array<string|int, mixed> $remainingSegments, FilterPath $segmentInfo, array<string|int, mixed> $init, array<string|int, mixed> &$binds, string $docRef[, array<string|int, mixed> $auth = [] ][, array<string|int, mixed>|null $currentFields = null ][, array<string|int, mixed> $fieldPath = [] ]) : string|null
Parameters
$remainingSegments : array<string|int, mixed>
$segmentInfo : FilterPath
$init : array<string|int, mixed>
$binds : array<string|int, mixed>
$docRef : string
$auth : array<string|int, mixed> = []
$currentFields : array<string|int, mixed>|null = null
$fieldPath : array<string|int, mixed> = []
Return values
string|null

buildEdgeTraversal()

Build edge traversal

private buildEdgeTraversal(array<string|int, mixed> $remainingSegments, FilterPath $segmentInfo, array<string|int, mixed> $init, array<string|int, mixed> &$binds, string $docRef[, array<string|int, mixed> $availableEdges = [] ][, array<string|int, mixed> $auth = [] ]) : string|null
Parameters
$remainingSegments : array<string|int, mixed>

The remaining path segments to process.

$segmentInfo : FilterPath

The current segment information with nested relations.

$init : array<string|int, mixed>

The original filter parameters.

$binds : array<string|int, mixed>

The bind variables array.

$docRef : string

The current document reference.

$availableEdges : array<string|int, mixed> = []

The edges definitions in scope at this level.

$auth : array<string|int, mixed> = []

The caller's permission context. The relation itself is gated here; the target model's own projection then gates the leaf below.

Tags
throws
BindException
ConstantException
ContainerExceptionInterface
DependencyException
NotFoundException
NotFoundExceptionInterface
ReflectionException

If edge configuration is invalid or not found.

RequestValidationException

When the request itself is refused — an unusable quant, or an operator this leaf cannot honour.

RuntimeException

When the edge or its model cannot be resolved.

UnsupportedOperationException
ValidationException
Return values
string|null —

The AQL condition for the edge traversal, false when the relation is refused, or null when the inner condition could not be resolved.

buildFilterRecursive()

Build filter condition recursively through path segments.

private buildFilterRecursive(array<string|int, mixed> $segments, array<string|int, mixed> $filters, array<string|int, mixed> $init, array<string|int, mixed> &$binds, string $docRef[, array<string|int, mixed> $parentPath = [] ][, array<string|int, mixed> $currentEdges = [] ][, array<string|int, mixed> $currentJoins = [] ][, array<string|int, mixed> $auth = [] ][, array<string|int, mixed>|null $currentFields = null ][, array<string|int, mixed> $fieldPath = [] ]) : string|null
Parameters
$segments : array<string|int, mixed>

Remaining segments to process; the first is consumed here.

$filters : array<string|int, mixed>

The AQL::FILTERS configuration of the current level.

$init : array<string|int, mixed>

The original filter parameters.

$binds : array<string|int, mixed>

The bind variables, populated by reference.

$docRef : string

The document reference of the current level.

$parentPath : array<string|int, mixed> = []

The accumulated path from parent segments, used for error reporting and for the full leaf key.

$currentEdges : array<string|int, mixed> = []

The edges definitions in scope, empty to fall back to the model's own.

$currentJoins : array<string|int, mixed> = []

The joins definitions in scope, empty to fall back to the model's own.

$auth : array<string|int, mixed> = []

The caller's permission context.

$currentFields : array<string|int, mixed>|null = null

The projection of the model being walked — it follows the relations, so a leaf is always gated against the fields of the model that actually holds it. null when the model declares no projection.

$fieldPath : array<string|int, mixed> = []

The path relative to $currentFields, extended by each nested object and reset whenever a relation is crossed.

Tags
throws
BindException
ConstantException
ContainerExceptionInterface
DependencyException
NotFoundException
NotFoundExceptionInterface
ReflectionException
RequestValidationException

When the request itself is refused.

RuntimeException

When a relation reference cannot be resolved.

UnsupportedOperationException
ValidationException
Return values
string|null —

The AQL condition, or null when the segment is not declared filterable or no handler could be found for the leaf.

buildInnerListCondition()

The condition on a list named last inside another list (`stops[*].scans[*]`) : a `match` on its elements, or how many of them there are.

private buildInnerListCondition(string $listKey, array<string|int, mixed> $declared, array<string|int, mixed> $init, array<string|int, mixed>|null &$binds, string $relativeBase, array<string|int, mixed>|null $currentFields, array<string|int, mixed> $auth, string $at) : string

Both read the elements flattened across the outer list — every scan of every stop. Unflattened, doc.stops[*].scans[*] is one list per stop, and its length is the number of stops.

  • A match keeps its guards : the sub-fields it names are held to the permissions of the projection and to the sub-filters the inner list declares, then the condition is built by the array filter, which flattens a nested list before counting. A quant is not applied : the level it would count is ambiguous.
  • Without one, the question is the cardinality, in the vocabulary of a list of the first level : nothing or any for « at least one », none for « not one », an integer for « at least n ». all is refused, there being no condition to satisfy.
Parameters
$listKey : string

The fully qualified key of the inner list, without its marker (doc.stops[*].scans).

$declared : array<string|int, mixed>

The sub-filters the inner list declares.

$init : array<string|int, mixed>

The filter parameters.

$binds : array<string|int, mixed>|null

The bind variables, populated by reference.

$relativeBase : string

The path of the inner list in the projection (stops.scans).

$currentFields : array<string|int, mixed>|null

The projection the path is resolved against.

$auth : array<string|int, mixed>

The caller's permission context.

$at : string

The list as the request spelled it, named by a refusal.

Tags
throws
BindException
RequestValidationException

When the match or the quantifier is refused.

UnsupportedOperationException
ValidationException
Return values
string

buildJoinTraversal()

Build join traversal

private buildJoinTraversal(array<string|int, mixed> $remainingSegments, FilterPath $segmentInfo, array<string|int, mixed> $init, array<string|int, mixed> &$binds, string $docRef[, array<string|int, mixed> $availableJoins = [] ][, array<string|int, mixed> $auth = [] ]) : string|null
Parameters
$remainingSegments : array<string|int, mixed>

The remaining path segments to process.

$segmentInfo : FilterPath

The current segment information with nested relations.

$init : array<string|int, mixed>

The original filter parameters.

$binds : array<string|int, mixed>

The bind variables array.

$docRef : string

The current document reference.

$availableJoins : array<string|int, mixed> = []

The joins definitions in scope at this level.

$auth : array<string|int, mixed> = []

The caller's permission context. The relation itself is gated here; the target model's own projection then gates the leaf below.

Tags
throws
BindException
ConstantException
ContainerExceptionInterface
DependencyException
NotFoundException
NotFoundExceptionInterface
ReflectionException
RequestValidationException

When the request itself is refused — an unusable quant, or an operator this leaf cannot honour.

RuntimeException

When the join, its model or its collection cannot be resolved.

UnsupportedOperationException
ValidationException
Return values
string|null —

The AQL condition for the join traversal, false when the relation is refused, or null when the inner condition could not be resolved.

buildLeafCondition()

Build the leaf condition by delegating to the flat filter helpers.

private buildLeafCondition(FilterPath $segmentInfo, array<string|int, mixed> $init, array<string|int, mixed> &$binds, string $docRef[, array<string|int, mixed>|null $currentFields = null ][, array<string|int, mixed> $fieldPath = [] ][, array<string|int, mixed> $auth = [] ]) : string|null

The last segment of the path names an actual field: its declared type selects the helper that knows how to compare it, and a custom callable is honoured as-is.

Parameters
$segmentInfo : FilterPath

The parsed leaf segment, carrying its declared type and its full path.

$init : array<string|int, mixed>

The original filter parameters.

$binds : array<string|int, mixed>

The bind variables, populated by reference.

$docRef : string

The document reference the leaf belongs to.

$currentFields : array<string|int, mixed>|null = null

The projection of the model holding the leaf.

$fieldPath : array<string|int, mixed> = []

The path relative to $currentFields, completed here with the leaf key to form the gated path.

$auth : array<string|int, mixed> = []

The caller's permission context.

Tags
throws
RequestValidationException

When the caller's own request is refused — the refusal is relayed to them, never swallowed into a dropped filter.

Return values
string|null —

The AQL condition, false when the field is refused by the permission gate, or null when no handler matches the declared type.

innerListFilters()

The sub-filters the last list of a path declares, walked from the sub-filters of the list the path starts under — empty when a level declares none.

private innerListFilters(array<string|int, mixed> $declared, array<string|int, string> $segments) : array<string|int, mixed>
Parameters
$declared : array<string|int, mixed>

The sub-filters of the outer list.

$segments : array<string|int, string>

The segments below it, down to the inner list.

Return values
array<string|int, mixed>

refuseUndeclaredArrayLeaf()

Refuses an element sub-field the list does not declare, following the path when it goes on under a declared object (`offers[*].seller.id`).

private refuseUndeclaredArrayLeaf(array<string|int, mixed> $declared, array<string|int, string> $segments, array<string|int, string> $path) : void

A list declared without sub-filters is free : nothing to check against, the same rule the match form applies. A path that goes on under a declared scalar is refused like any path under a leaf, with the spelling that would work.

Parameters
$declared : array<string|int, mixed>

The nested AQL::FILTERS of the list.

$segments : array<string|int, string>

The segments below the list.

$path : array<string|int, string>

The path of the list, as the request spelled it.

Tags
throws
RequestValidationException

When a segment is unknown, or goes on under a scalar.

On this page

Search results