buildPolymorphicEdgeVariable.php
Table of Contents
Functions
- buildPolymorphicEdgeVariable() : string
- Builds a single AQL 'LET' subquery for a *polymorphic* edge — an edge whose traversed collection is chosen at query time from a discriminator field of the start vertex (the parent document).
Functions
buildPolymorphicEdgeVariable()
Builds a single AQL 'LET' subquery for a *polymorphic* edge — an edge whose traversed collection is chosen at query time from a discriminator field of the start vertex (the parent document).
buildPolymorphicEdgeVariable(string|null $name[, array<string|int, mixed> $definition = [] ][, string $startVertex = AQL::DOC ][, ContainerInterface|null $container = null ][, array<string|int, mixed> $init = [] ]) : string
The whole branch machinery (guarding, per-branch permission gating, the
FALLBACK branch, the APPEND combine) lives in the shared
buildPolymorphicRelationVariable(); this function only supplies the
per-branch builder, which delegates to buildEdgeSubquery() (already a
parenthesized traversal). Each branch is a full edge definition, so it may
declare its own AQL::DIRECTION, AQL::MAX_DEPTH, etc.
The resulting LET always holds an array — exactly like a regular edge —
so the projection layer (aqlFieldObject())
unwraps it with FIRST() for a Filter::EDGE or keeps the whole array for a
Filter::EDGES.
Example output (two branches):
LET rel = APPEND(
( FOR vertex, edge IN OUTBOUND doc warehouse_edges
FILTER doc.kind == "warehouse"
RETURN { _key: vertex._key, name: vertex.name } ) ,
( FOR vertex, edge IN OUTBOUND doc company_edges
FILTER doc.kind == "company"
RETURN { _key: vertex._key, name: vertex.name } )
)
Parameters
- $name : string|null
-
The edge field name — also the default
LETvariable name. - $definition : array<string|int, mixed> = []
-
The polymorphic edge definition. Keys:
Arango::DISCRIMINATOR(string) Start-vertex field path deciding the branch (required).Arango::MAP(array) Non-emptytype => edge-definitiontable (required).Arango::UNIQUE(string|null) OptionalLETvariable name, overrides$name.Arango::SOURCE(string|null) Optional absolute path holding the traversal start-vertex_id; the traversal then departs fromdoc.<source>while the discriminator STAYS resolved on the parent document (doc.<discriminator>).Arango::FALLBACK(array|null) Edge definition for unmatched discriminator values (null= none).
- $startVertex : string = AQL::DOC
-
The AQL variable name of the start vertex.
- $container : ContainerInterface|null = null
-
Optional DI container used to resolve branch models.
- $init : array<string|int, mixed> = []
-
Optional associative array used for variable initialization.
Tags
Return values
string —The complete AQL 'LET' statement.