EdgeDefinition
Immutable value object describing one edge definition inside a named graph.
An edge definition tells ArangoDB that the edge collection
$collection connects documents stored in any of the
$from vertex collections to documents stored in any of the
$to vertex collections. The server uses this constraint to
reject inconsistent _from / _to values when an edge is created
or updated through the gharial endpoints (/_api/gharial/{graph}/edge/...).
$from and $to are typed as lists of collection names; either
can be empty (the gharial endpoint will reject an empty list at
addEdgeDefinition() time — we don't pre-validate to keep the VO
dumb on purpose).
Construct directly or via the static fromArray() factory
when consuming a GET /_api/gharial/{name} response.
Example:
$employs = new EdgeDefinition
(
collection : 'employs' ,
from : [ 'companies' ] ,
to : [ 'people' ] ,
) ;
$db->createGraph( 'workplaces' , [ $employs ] ) ;
Tags
Table of Contents
Constants
- COLLECTION : string = 'collection'
- Wire field carrying the edge collection name.
- FROM : string = 'from'
- Wire field carrying the list of allowed `_from` vertex collections.
- TO : string = 'to'
- Wire field carrying the list of allowed `_to` vertex collections.
Properties
- $collection : string
- $from : array<string|int, mixed>
- $to : array<string|int, mixed>
Methods
- __construct() : mixed
- fromArray() : self
- Builds an {@see EdgeDefinition} from a wire object as returned by `GET /_api/gharial/{name}` under `edgeDefinitions`.
-
toArray()
: array{collection: string, from: array
, to: array } - Returns the definition as a plain associative array — the shape the gharial endpoint expects on the request side.
Constants
COLLECTION
Wire field carrying the edge collection name.
public
string
COLLECTION
= 'collection'
FROM
Wire field carrying the list of allowed `_from` vertex collections.
public
string
FROM
= 'from'
TO
Wire field carrying the list of allowed `_to` vertex collections.
public
string
TO
= 'to'
Properties
$collection
public
string
$collection
$from
public
array<string|int, mixed>
$from
$to
public
array<string|int, mixed>
$to
Methods
__construct()
public
__construct(string $collection, array<int, string> $from, array<int, string> $to) : mixed
Parameters
- $collection : string
-
Name of the edge collection.
- $from : array<int, string>
-
Vertex collections allowed as
_fromsource. - $to : array<int, string>
-
Vertex collections allowed as
_totarget.
fromArray()
Builds an {@see EdgeDefinition} from a wire object as returned by `GET /_api/gharial/{name}` under `edgeDefinitions`.
public
static fromArray(array<string, mixed> $data) : self
Missing or non-array from / to fields fall back to an empty
list; a missing collection name yields an empty string (server
always emits it, the fallback is purely defensive).
Parameters
- $data : array<string, mixed>
Return values
selftoArray()
Returns the definition as a plain associative array — the shape the gharial endpoint expects on the request side.
public
toArray() : array{collection: string, from: array, to: array}