RoutingCallback
RoutingCallback allows you to provide callbacks into the routing
Synopsis
Section titled “Synopsis”abstract class RoutingCallback extends ParameterHolder
| Extends | ParameterHolder |
| Since | 1.0.0 |
| Source | Routing/RoutingCallback.php |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
$context | mixed | protected. |
$route | mixed | protected. |
Methods
Section titled “Methods”| Method | Description |
|---|---|
getContext(): Context | Retrieve the current application context. |
initialize(Context $context, array<mixed, mixed> &$route): void | Initialize the callback instance. |
onGenerate(array<mixed, mixed> $defaultParameters, array<mixed, mixed> &$userParameters, array<mixed, mixed> &$userOptions): bool | Gets executed when the route of this callback is about to be reverse generated into an URL. |
onMatched(array<string, mixed> &$parameters, mixed $legacyContainer = null): bool | Executed when the route matched (container-less). |
onNotMatched(mixed $legacyContainer = null): void | Executed when the route did NOT match (container-less). |
reset(): void | Returns the callback to its uninitialized state. |
getContext()
Section titled “getContext()”final public function getContext(): Context
Retrieve the current application context.
Returns Context — An Context instance.
| Throws | When |
|---|---|
InitializationException | If this RoutingCallback has not been initialized yet. |
initialize()
Section titled “initialize()”public function initialize(Context $context, array<mixed, mixed> &$route): void
Initialize the callback instance.
An array with information about the route.
| Parameter | Type | Description |
|---|---|---|
$context | Context | An Context instance. |
$route | array``<``mixed``, ``mixed``> | An array with information about the route. |
onGenerate()
Section titled “onGenerate()”public function onGenerate(array<mixed, mixed> $defaultParameters, array<mixed, mixed> &$userParameters, array<mixed, mixed> &$userOptions): bool
Gets executed when the route of this callback is about to be reverse generated into an URL.
The options the user supplied to Routing::gen().
| Parameter | Type | Description |
|---|---|---|
$defaultParameters | array``<``mixed``, ``mixed``> | The default parameters stored in the route. |
$userParameters | array``<``mixed``, ``mixed``> | The parameters the user supplied to Routing::gen(). |
$userOptions | array``<``mixed``, ``mixed``> | The options the user supplied to Routing::gen(). |
Returns bool — Whether this route part should be generated.
onMatched()
Section titled “onMatched()”public function onMatched(array<string, mixed> &$parameters, mixed $legacyContainer = null): bool
Executed when the route matched (container-less).
Unused; retained for signature compatibility.
| Parameter | Type | Description |
|---|---|---|
$parameters | array``<``string``, ``mixed``> | Parameters generated by this route (modifiable). |
$legacyContainer | mixed | Unused; retained for signature compatibility. |
Returns bool — true to accept match; false to treat as not matched.
onNotMatched()
Section titled “onNotMatched()”public function onNotMatched(mixed $legacyContainer = null): void
Executed when the route did NOT match (container-less).
Unused; retained for signature compatibility.
| Parameter | Type | Description |
|---|---|---|
$legacyContainer | mixed | Unused; retained for signature compatibility. |
reset()
Section titled “reset()”public function reset(): void
Returns the callback to its uninitialized state.
Drops the context and route references handed in by RoutingCallback::initialize() and clears every parameter held on the instance, so a container-managed callback can be reused for the next request without carrying anything over. RoutingCallback::getContext() throws again afterwards until the callback is initialized once more.
Inherited methods
Section titled “Inherited methods”These come from an ancestor and are documented where they are declared.
| Method | Declared in | Description |
|---|---|---|
appendParameter() | ParameterHolder | Append a parameter. |
appendParameterByRef() | ParameterHolder | Append a parameter by reference. |
clearParameters() | ParameterHolder | Clear all parameters associated with this request. |
getFlatParameterNames() | ParameterHolder | Retrieve an array of flattened parameter names. |
getParameter() | ParameterHolder | Retrieve a parameter. |
getParameterNames() | ParameterHolder | Retrieve an array of parameter names. |
getParameters() | ParameterHolder | Retrieve an array of parameters. |
hasParameter() | ParameterHolder | Indicates whether or not a parameter exists. |
removeParameter() | ParameterHolder | Remove a parameter. |
setParameter() | ParameterHolder | Set a parameter. |
setParameterByRef() | ParameterHolder | Set a parameter by reference. |
setParameters() | ParameterHolder | Set an array of parameters. |
setParametersByRef() | ParameterHolder | Set an array of parameters by reference. |