EdgesController extends Controller
Generic controller for managing edge relationships between two vertex collections.
Provides post() and delete() methods to create and remove edges
between a source vertex (from) and a target vertex (to).
Both source and target vertex IDs are read from the URL route placeholders:
{id}for the source vertex (Schema::ID){targetId}for the target vertex
POST also accepts an optional body for edge properties.
Tags
Table of Contents
Constants
- EDGES : string = 'edges'
- Initialization key for the Edges model dependency.
- FROM : string = 'from'
- Initialization key for the source vertex Documents model.
- TARGET_ID : string = 'targetId'
- URL placeholder name for the target vertex ID.
- TO : string = 'to'
- Initialization key for the target vertex Documents model.
Properties
- $edges : Edges|null
- The Edges model for the edge collection.
- $from : Documents|null
- The Documents model for the source vertex collection.
- $to : Documents|null
- The Documents model for the target vertex collection.
Methods
- __construct() : mixed
- Creates a new EdgesController instance.
- delete() : mixed
- Removes an edge between two vertices.
- post() : mixed
- Creates a new edge between two vertices.
Constants
EDGES
Initialization key for the Edges model dependency.
public
string
EDGES
= 'edges'
FROM
Initialization key for the source vertex Documents model.
public
string
FROM
= 'from'
TARGET_ID
URL placeholder name for the target vertex ID.
public
string
TARGET_ID
= 'targetId'
TO
Initialization key for the target vertex Documents model.
public
string
TO
= 'to'
Properties
$edges
The Edges model for the edge collection.
protected
Edges|null
$edges
= null
$from
The Documents model for the source vertex collection.
protected
Documents|null
$from
= null
$to
The Documents model for the target vertex collection.
protected
Documents|null
$to
= null
Methods
__construct()
Creates a new EdgesController instance.
public
__construct(Container $container[, array<string|int, mixed> $init = [] ]) : mixed
Parameters
- $container : Container
-
The DI container reference.
- $init : array<string|int, mixed> = []
-
Supports:
- self::EDGES: Edges model service ID or instance
- self::FROM: Documents model for the source vertex
- self::TO: Documents model for the target vertex
Tags
delete()
Removes an edge between two vertices.
public
delete([ServerRequestInterface|null $request = null ][, ResponseInterface|null $response = null ][, array<string|int, mixed> $args = [] ][, array<string|int, mixed> $init = [] ]) : mixed
Reads both vertex IDs from the route placeholders:
{id}for the source vertex{targetId}for the target vertex
Parameters
- $request : ServerRequestInterface|null = null
-
The PSR-7 request object.
- $response : ResponseInterface|null = null
-
The PSR-7 response object.
- $args : array<string|int, mixed> = []
-
Route placeholders (expects Schema::ID and self::TARGET_ID).
- $init : array<string|int, mixed> = []
-
Optional settings.
Tags
Return values
mixed —200 on success, 404 if vertex or edge not found.
post()
Creates a new edge between two vertices.
public
post([ServerRequestInterface|null $request = null ][, ResponseInterface|null $response = null ][, array<string|int, mixed> $args = [] ][, array<string|int, mixed> $init = [] ]) : mixed
Reads both vertex IDs from the route placeholders:
{id}for the source vertex{targetId}for the target vertex
The request body is optional and can contain additional edge properties.
Parameters
- $request : ServerRequestInterface|null = null
-
The PSR-7 request object.
- $response : ResponseInterface|null = null
-
The PSR-7 response object.
- $args : array<string|int, mixed> = []
-
Route placeholders (expects Schema::ID and self::TARGET_ID).
- $init : array<string|int, mixed> = []
-
Optional settings.
Tags
Return values
mixed —201 on success, 400 if missing data, 404 if vertex not found, 409 if edge exists.