Oihana PHP Arango

TraversalRoute extends Route

Declares, in a single definition, the four navigation sub-routes of a {@see TraversalController} (which walks a self-referential edge — a category tree, an org chart, a thread…).

Given a base route of /{collection}, it registers, on the item URL /{collection}/{id} :

Verb Path Controller method
GET /{collection}/{id}/parent getParent
GET /{collection}/{id}/children getChildren
GET /{collection}/{id}/ancestors getAncestors
GET /{collection}/{id}/descendants getDescendants

The {id} placeholder is configurable via Route::ROUTE_PLACEHOLDER (default {id:[0-9]+}). Method bindings use the TraversalController constants (no magic strings). Register it before the generic document route so the literal suffixes are matched first.

// definitions/routes.php
Routes::CATEGORIES_TREE => fn( Container $c ) => new TraversalRoute( $c,
[
    Route::CONTROLLER_ID => Controllers::CATEGORIES_TRAVERSAL , // a TraversalController(edge: …)
    Route::ROUTE         => '/thesaurus/products/categories'  ,
]) ,
Tags
see
TraversalController
ArrayPropertyRoute
DocumentRoute

Table of Contents

Constants

ANCESTORS  : string = 'ancestors'
The `/ancestors` sub-route suffix.
CHILDREN  : string = 'children'
The `/children` sub-route suffix.
DESCENDANTS  : string = 'descendants'
The `/descendants` sub-route suffix.
PARENT  : string = 'parent'
The `/parent` sub-route suffix.

Methods

__invoke()  : void
Registers the four navigation sub-routes on the application.
subRoute()  : Route
Builds a single GET sub-route bound to the given controller method.

Constants

ANCESTORS

The `/ancestors` sub-route suffix.

public string ANCESTORS = 'ancestors'

CHILDREN

The `/children` sub-route suffix.

public string CHILDREN = 'children'

DESCENDANTS

The `/descendants` sub-route suffix.

public string DESCENDANTS = 'descendants'

PARENT

The `/parent` sub-route suffix.

public string PARENT = 'parent'

Methods

__invoke()

Registers the four navigation sub-routes on the application.

public __invoke() : void
Tags
throws
ContainerExceptionInterface
DependencyException
NotFoundException
NotFoundExceptionInterface

subRoute()

Builds a single GET sub-route bound to the given controller method.

private subRoute(string $route, string $method) : Route
Parameters
$route : string

The route pattern.

$method : string

The controller method name to bind.

Tags
throws
ContainerExceptionInterface
DependencyException
NotFoundException
NotFoundExceptionInterface
Return values
Route
On this page

Search results