Oihana PHP

PrepareOrRedirectArgumentTrait uses trait:short

Resolves a route argument through the controller redirection table.

This trait maps an incoming identifier to its canonical replacement when a redirection is declared for it. It looks up the $redirects[$redirectID] table (provided by RedirectsTrait) and returns the mapped value when the identifier has an entry; otherwise the original identifier is returned unchanged.

Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Properties

$redirects  : array<string|int, mixed>
The redirects settings.

Methods

initializeRedirects()  : void
Initialize the `redirects` property from the initialization array.
prepareOrRedirectArgument()  : mixed
Prepares an argument and redirects it if possible.

Properties

$redirects

The redirects settings.

public array<string|int, mixed> $redirects = []

Methods

initializeRedirects()

Initialize the `redirects` property from the initialization array.

public initializeRedirects([array<string|int, mixed> $init = [] ]) : void

Reads the ControllerParam::REDIRECTS key, defaulting to an empty array when absent.

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

Optional initialization array.

prepareOrRedirectArgument()

Prepares an argument and redirects it if possible.

public prepareOrRedirectArgument(string|null $id, string|null $redirectID) : mixed
Parameters
$id : string|null

The incoming identifier to resolve against the redirection table.

$redirectID : string|null

The key selecting which redirection table to use, or null to skip redirection.

Return values
mixed

The redirected value when a mapping exists, otherwise the original $id.

On this page

Search results