Oihana PHP Arango

ArrayPropertyRoute extends Route

Declares, in a single definition, the four REST sub-resource routes of an {@see ArrayPropertyController} (which exposes the element-level operations of an embedded array property).

Given a base route of /{collection}/{id}/{property}, it registers:

Verb Path Controller method
POST /{collection}/{id}/{property} addItem
DELETE /{collection}/{id}/{property}/{value} removeItem
PATCH /{collection}/{id}/{property}/{value} moveItem
GET /{collection}/{id}/{property}/{value} hasItem

The {value} placeholder is configurable via self::VALUE_PLACEHOLDER (default value). Method bindings use the ArrayPropertyController constants (no magic strings).

// definitions/routes.php
Routes::PLAYLIST_TRACKS => fn( Container $c ) => new ArrayPropertyRoute( $c,
[
    Route::CONTROLLER_ID => Controllers::PLAYLIST_TRACKS , // an ArrayPropertyController(property: 'tracks')
    Route::ROUTE         => '/playlists/{id}/tracks'      ,
]) ,
Tags
see
ArrayPropertyController
DocumentRoute

Table of Contents

Constants

VALUE_PLACEHOLDER  : string = 'valuePlaceholder'
The init key customizing the `{value}` placeholder (name, optionally with a regex constraint).

Properties

$valuePlaceholder  : string
The `{value}` placeholder (a Slim segment name, optionally with a regex), default `value`.

Methods

__construct()  : mixed
Creates a new ArrayPropertyRoute instance.
__invoke()  : void
Registers the four array sub-resource routes on the application.
itemRoute()  : Route
Builds a single sub-resource route bound to the given controller method.

Constants

VALUE_PLACEHOLDER

The init key customizing the `{value}` placeholder (name, optionally with a regex constraint).

public string VALUE_PLACEHOLDER = 'valuePlaceholder'

Properties

$valuePlaceholder

The `{value}` placeholder (a Slim segment name, optionally with a regex), default `value`.

public string $valuePlaceholder = 'value'

Methods

__construct()

Creates a new ArrayPropertyRoute instance.

public __construct(Container $container[, array<string|int, mixed> $init = [] ]) : mixed
Parameters
$container : Container

The DI container.

$init : array<string|int, mixed> = []

The route initialization options (see Route), plus self::VALUE_PLACEHOLDER to customize the {value} segment.

Tags
throws
ContainerExceptionInterface
DependencyException
NotFoundException
NotFoundExceptionInterface

__invoke()

Registers the four array sub-resource routes on the application.

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

itemRoute()

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

private itemRoute(string $clazz, string $route, string $method) : Route
Parameters
$clazz : string

The Route subclass (PostRoute, DeleteRoute, …).

$route : string

The route pattern.

$method : string

The controller method name to bind.

Return values
Route
On this page

Search results