GetRoute extends HttpMethodRoute
Represents a route that registers an HTTP GET verb.
This class extends MethodRoute and implements the registerRoute
template method to call the Slim App's get() method.
By convention, it sets the default controller method to 'get'.
Tags
Table of Contents
Constants
- APP : string = 'app'
- Array keys for route initialization
- CLAZZ : string = 'clazz'
- CONTROLLER_ID : string = 'controllerID'
- DEFAULT_OWNER_PLACEHOLDER : string = 'owner:[0-9]+'
- Default owner pattern for numeric owner IDs
- DEFAULT_PREFIX : string = 'api'
- Default API prefix for route names
- DEFAULT_ROUTE_PLACEHOLDER : string = 'id:[0-9]+'
- Default route pattern for numeric IDs
- FLAGS : string = 'flags'
- INTERNAL_METHOD : string = \oihana\enums\http\HttpMethod::get
- By convention, a GET route calls the 'get' method on the controller, unless specified otherwise in $init.
- METHOD : string = 'method'
- NAME : string = 'name'
- OWNER_PATTERN : string = 'ownerPattern'
- OWNER_PLACEHOLDER : string = 'ownerPlaceHolder'
- PATCH_PATTERN : string = 'patchPattern'
- PATCH_PLACE_HOLDER : string = 'patchPlaceHolder'
- PREFIX : string = 'prefix'
- PROPERTY : string = 'property'
- ROUTE : string = 'route'
- ROUTE_PATTERN : string = 'routePattern'
- ROUTE_PLACEHOLDER : string = 'routePattern'
- ROUTES : string = 'routes'
- SUFFIX : string = 'suffix'
Properties
- $controllerID : string|null
- $method : string|mixed
- The name of the method to call in the controller to invoke with this route.
- $name : string|null
- $ownerPlaceholder : string|null
- $prefix : string
- $property : string
- $route : string|null
- $routePlaceholder : string
- $routes : array<string|int, mixed>|null
- $suffix : string
Methods
- __construct() : mixed
- Creates a new MethodRoute instance.
- __invoke() : void
- Main entry point.
- create() : Route|null
- Creates a new Route instance from a definition array or Route object.
- dotify() : string
- Converts a route path from 'foo/bar' to 'foo.bar'.
- execute() : void
- Executes a callable or an array of callables.
- getName() : string
- Returns the fully qualified route name, including prefix and suffix.
- getRoute() : string
- Returns the safe main route representation starting with '/'.
- initializeMethod() : $this
- Initialize the internal method property.
- registerRoute() : void
- Implements the template method to register the route with the HTTP GET verb.
Constants
APP
Array keys for route initialization
public
string
APP
= 'app'
CLAZZ
public
string
CLAZZ
= 'clazz'
CONTROLLER_ID
public
string
CONTROLLER_ID
= 'controllerID'
DEFAULT_OWNER_PLACEHOLDER
Default owner pattern for numeric owner IDs
public
string
DEFAULT_OWNER_PLACEHOLDER
= 'owner:[0-9]+'
DEFAULT_PREFIX
Default API prefix for route names
public
string
DEFAULT_PREFIX
= 'api'
DEFAULT_ROUTE_PLACEHOLDER
Default route pattern for numeric IDs
public
string
DEFAULT_ROUTE_PLACEHOLDER
= 'id:[0-9]+'
FLAGS
public
string
FLAGS
= 'flags'
INTERNAL_METHOD
By convention, a GET route calls the 'get' method on the controller, unless specified otherwise in $init.
public
string
INTERNAL_METHOD
= \oihana\enums\http\HttpMethod::get
METHOD
public
string
METHOD
= 'method'
NAME
public
string
NAME
= 'name'
OWNER_PATTERN
public
string
OWNER_PATTERN
= 'ownerPattern'
OWNER_PLACEHOLDER
public
string
OWNER_PLACEHOLDER
= 'ownerPlaceHolder'
PATCH_PATTERN
public
string
PATCH_PATTERN
= 'patchPattern'
PATCH_PLACE_HOLDER
public
string
PATCH_PLACE_HOLDER
= 'patchPlaceHolder'
PREFIX
public
string
PREFIX
= 'prefix'
PROPERTY
public
string
PROPERTY
= 'property'
ROUTE
public
string
ROUTE
= 'route'
ROUTE_PATTERN
public
string
ROUTE_PATTERN
= 'routePattern'
ROUTE_PLACEHOLDER
public
string
ROUTE_PLACEHOLDER
= 'routePattern'
ROUTES
public
string
ROUTES
= 'routes'
SUFFIX
public
string
SUFFIX
= 'suffix'
Properties
$controllerID
public
string|null
$controllerID
= null
Controller ID registered in DI container
$method
The name of the method to call in the controller to invoke with this route.
public
string|mixed
$method
$name
public
string|null
$name
= null
Route name
$ownerPlaceholder
public
string|null
$ownerPlaceholder
= self::DEFAULT_OWNER_PLACEHOLDER
The owner route placeholder.
$prefix
public
string
$prefix
= self::DEFAULT_PREFIX
Route name prefix
$property
public
string
$property
= \oihana\enums\Char::EMPTY
Property name in complex routes
$route
public
string|null
$route
= null
The route expression.
$routePlaceholder
public
string
$routePlaceholder
= self::DEFAULT_ROUTE_PLACEHOLDER
The route placeholder.
$routes
public
array<string|int, mixed>|null
$routes
= null
Nested route definitions.
$suffix
public
string
$suffix
= \oihana\enums\Char::EMPTY
Route name suffix
Methods
__construct()
Creates a new MethodRoute instance.
public
__construct(Container $container[, array<string|int, mixed> $init = [] ]) : mixed
Parameters
- $container : Container
-
The DI Container reference.
- $init : array<string|int, mixed> = []
-
The optional settings object.
Tags
__invoke()
Main entry point.
public
__invoke() : void
Validates the controller/method and calls the registerRoute template method.
Tags
create()
Creates a new Route instance from a definition array or Route object.
public
create(array<string|int, mixed>|Route|null $definition) : Route|null
Parameters
- $definition : array<string|int, mixed>|Route|null
-
Route definition or existing Route
Return values
Route|null —The created Route instance or null if invalid
dotify()
Converts a route path from 'foo/bar' to 'foo.bar'.
public
dotify(string $route) : string
Parameters
- $route : string
-
Route path
Return values
string —Dotified route path
execute()
Executes a callable or an array of callables.
public
execute(mixed $routes) : void
Parameters
- $routes : mixed
-
Callable or array of callables
getName()
Returns the fully qualified route name, including prefix and suffix.
public
getName() : string
Return values
string —Route name
getRoute()
Returns the safe main route representation starting with '/'.
public
getRoute() : string
Return values
string —Route path
initializeMethod()
Initialize the internal method property.
public
initializeMethod([array<string|int, mixed> $init = [] ]) : $this
Parameters
- $init : array<string|int, mixed> = []
-
The initialization array, optionally carrying a
methodoverride.
Return values
$this —Returns the current instance for method chaining.
registerRoute()
Implements the template method to register the route with the HTTP GET verb.
protected
registerRoute(callable $handler) : void
Parameters
- $handler : callable
-
The handler (e.g., [$controller, 'get'])