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
- Build a nested object traversal (`address.city`).
- buildEdgeTraversal() : string|null
- Build edge traversal
- buildFilterRecursive() : string|null
- Build filter condition recursively through path segments.
- buildJoinTraversal() : string|null
- Build join traversal
- buildLeafCondition() : string|null
- Build the leaf condition by delegating to the flat filter helpers.
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
falserather than dropped.
Tags
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
Return values
string|null —The AQL condition, or false when the sub-field is refused by the
permission gate.
buildDocumentTraversal()
Build a nested object traversal (`address.city`).
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
A nested document stays inside the SAME model, so the projection is carried over unchanged and only the relative field path is extended.
Parameters
- $remainingSegments : array<string|int, mixed>
-
The segments below the object.
- $segmentInfo : FilterPath
-
The parsed object 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 object.
- $auth : array<string|int, mixed> = []
-
The caller's permission context.
- $currentFields : array<string|int, mixed>|null = null
-
The projection of the model holding the object.
- $fieldPath : array<string|int, mixed> = []
-
The path relative to
$currentFields, extended with this object's key before recursing.
Tags
Return values
string|null —The AQL condition built from the segments below, or null when none
could be resolved.
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
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::FILTERSconfiguration 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.
nullwhen 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
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.
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
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
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.