Orpheus

HttpRoute extends ControllerRoute
in package

Route for Orpheus.

Table of Contents

Constants

METHOD_DELETE  = 'DELETE'
METHOD_GET  = 'GET'
METHOD_POST  = 'POST'
METHOD_PUT  = 'PUT'
PROVIDERS_KEY  = 'providers'
REQUIREMENTS_KEY  = 'require-packages'

Properties

$controller  : AbstractController
The running controller
$controllerClass  : string
The class of called controller associated to this route
$defaultResponse  : string
Default response if controller returns is invalid
$initialized  : bool
Define this class initialized
$knownMethods  : array<string|int, mixed>
All known methods
$methods  : array<string|int, mixed>
The methods allowed to reach this route
$name  : string
A route is identified by its name
$options  : array<string|int, mixed>
Non-processed options in route configuration
$outputResponses  : array<string|int, mixed>
Registered response class for output option
$path  : string
The path determine how to access this route
$pathRegex  : string|null
Path with converted regex
$pathVariables  : array<string|int, string>
Variables in path
$restrictTo  : array<string|int, mixed>
Restrictions to access this route
$routes  : array<string|int, mixed>
Registered routes
$routesRestrictions  : array<string|int, mixed>
Registered route restrictions
$typesRegex  : array<string|int, mixed>
Registered regex for a type

Methods

__toString()  : string
Get route as string
formatUrl()  : string
Format the current route to get a URL from path
getController()  : AbstractController
getControllerClass()  : string
Get the controller class
getCurrentRouteName()  : string
Get the current route name
getKnownMethods()  : array<string|int, string>
Get the known HTTP methods
getLink()  : string
Get the link to this route
getName()  : string
Get the name
getOptions()  : array<string|int, mixed>
Get route options
getOutputResponse()  : mixed
Get the output response
getPath()  : string
Get the path
getRoute()  : HttpRoute|null
Get the route object for the $route name
getRoutes()  : array<string|int, ControllerRoute>
Get all registered routes These one are commonly stored in the configuration (routes.yaml)
initialize()  : void
Initialize the route class by loading the configuration (once only)
instantiateController()  : AbstractController
Instantiate the controller and return it
isAccessible()  : bool
Test if the route is accessible in the current context using restrictTo This method is sensitive to CHECK_MODULE_ACCESS constant, a true value make it always accessible, never use it in production
isInitialized()  : bool
Test if the class is initialized
isMatchingRequest()  : bool
Test current route is matching request
parsePath()  : string
Normalize path by removing any trailing slash
register()  : void
Register route by $name
registerAccessRestriction()  : void
Register the access restriction $type This will be used by isAccessible()
registerConfig()  : void
Register route by $name from config
run()  : OutputResponse
Run the $request by processing the matching controller
setOutputResponse()  : void
Set the output response
setTypeRegex()  : void
Set the regex of a type, used to parse paths
__construct()  : mixed
Constructor
extractVariable()  : void
Extract variable from configuration string
generatePathRegex()  : void
Generate all regex of the path from extracted variables
loadRoutes()  : void
Load routes from $package or app (if null)
mergeRoutes()  : void
Merge routes array with routes' logic
populateRoutesFromFile()  : void
Populate given array with routes from $file in $package (or app if null)

Constants

METHOD_DELETE

public mixed METHOD_DELETE = 'DELETE'

METHOD_POST

public mixed METHOD_POST = 'POST'

Properties

$controllerClass

The class of called controller associated to this route

protected string $controllerClass

The controller class

$defaultResponse

Default response if controller returns is invalid

protected string $defaultResponse

$initialized

Define this class initialized

protected static bool $initialized = false

$knownMethods

All known methods

protected static array<string|int, mixed> $knownMethods = [self::METHOD_GET, self::METHOD_POST, self::METHOD_PUT, self::METHOD_DELETE]

$methods

The methods allowed to reach this route

protected array<string|int, mixed> $methods

$name

A route is identified by its name

protected string $name

The name

$options

Non-processed options in route configuration

protected array<string|int, mixed> $options

$outputResponses

Registered response class for output option

protected static array<string|int, mixed> $outputResponses = []

$path

The path determine how to access this route

protected string $path

The path

$pathRegex

Path with converted regex

protected string|null $pathRegex = null

$pathVariables

Variables in path

protected array<string|int, string> $pathVariables = []

$restrictTo

Restrictions to access this route

protected array<string|int, mixed> $restrictTo

$routes

Registered routes

protected static array<string|int, mixed> $routes = []

$routesRestrictions

Registered route restrictions

protected static array<string|int, mixed> $routesRestrictions = []

$typesRegex

Registered regex for a type

protected static array<string|int, mixed> $typesRegex = []

Methods

__toString()

Get route as string

public __toString() : string
Return values
string

formatUrl()

Format the current route to get a URL from path

public formatUrl([array<string|int, string> $values = [] ][, array<string|int, mixed> $parameters = [] ]) : string
Parameters
$values : array<string|int, string> = []
$parameters : array<string|int, mixed> = []
Return values
string

getControllerClass()

Get the controller class

public getControllerClass() : string
Return values
string

getCurrentRouteName()

Get the current route name

public static getCurrentRouteName() : string
Return values
string

getKnownMethods()

Get the known HTTP methods

public static getKnownMethods() : array<string|int, string>
Return values
array<string|int, string>

Get the link to this route

public abstract getLink() : string
Return values
string

getName()

Get the name

public abstract getName() : string
Return values
string

getOptions()

Get route options

public getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getOutputResponse()

Get the output response

public static getOutputResponse(string $output) : mixed
Parameters
$output : string

getPath()

Get the path

public getPath() : string
Return values
string

getRoute()

Get the route object for the $route name

public static getRoute(string $name) : HttpRoute|null
Parameters
$name : string
Return values
HttpRoute|null

initialize()

Initialize the route class by loading the configuration (once only)

public static initialize() : void

isAccessible()

Test if the route is accessible in the current context using restrictTo This method is sensitive to CHECK_MODULE_ACCESS constant, a true value make it always accessible, never use it in production

public abstract isAccessible() : bool
Return values
bool

isInitialized()

Test if the class is initialized

public static isInitialized() : bool
Return values
bool

parsePath()

Normalize path by removing any trailing slash

public static parsePath(string $path) : string
Parameters
$path : string
Return values
string

register()

Register route by $name

public static register(string $name, string $path, string $controller, array<string|int, mixed>|null $methods, array<string|int, mixed>|null $restrictTo, string $defaultResponse[, array<string|int, mixed> $options = [] ]) : void
Parameters
$name : string
$path : string
$controller : string
$methods : array<string|int, mixed>|null
$restrictTo : array<string|int, mixed>|null
$defaultResponse : string
$options : array<string|int, mixed> = []
Tags
throws
Exception

registerAccessRestriction()

Register the access restriction $type This will be used by isAccessible()

public static registerAccessRestriction(string $type, callable $callable) : void
Parameters
$type : string
$callable : callable
Tags
uses
isAccessible()

registerConfig()

Register route by $name from config

public static registerConfig(string $name, array<string|int, mixed> $config) : void
Parameters
$name : string
$config : array<string|int, mixed>
Tags
throws
Exception

setOutputResponse()

Set the output response

public static setOutputResponse(string $output, string $responseClass) : void
Parameters
$output : string
$responseClass : string

setTypeRegex()

Set the regex of a type, used to parse paths

public static setTypeRegex(string $type, string $regex) : void
Parameters
$type : string
$regex : string

__construct()

Constructor

protected __construct(string $name, string $path, string $controller, array<string|int, mixed> $methods, array<string|int, mixed>|null $restrictTo, string $defaultResponse, array<string|int, mixed> $options) : mixed
Parameters
$name : string
$path : string
$controller : string
$methods : array<string|int, mixed>
$restrictTo : array<string|int, mixed>|null
$defaultResponse : string
$options : array<string|int, mixed>

extractVariable()

Extract variable from configuration string

protected static extractVariable(string $value[, string|null &$variable = null ][, string|null &$regex = null ]) : void
Parameters
$value : string
$variable : string|null = null
$regex : string|null = null

generatePathRegex()

Generate all regex of the path from extracted variables

protected generatePathRegex() : void

loadRoutes()

Load routes from $package or app (if null)

protected static loadRoutes(array<string|int, mixed> &$routes[, string|null $package = null ]) : void
Parameters
$routes : array<string|int, mixed>
$package : string|null = null

mergeRoutes()

Merge routes array with routes' logic

protected static mergeRoutes(array<string|int, mixed> &$routes, array<string|int, mixed> $added) : void
Parameters
$routes : array<string|int, mixed>
$added : array<string|int, mixed>

populateRoutesFromFile()

Populate given array with routes from $file in $package (or app if null)

protected static populateRoutesFromFile(array<string|int, mixed> &$routes, string $file[, string|null $package = null ][, bool $optional = false ]) : void
Parameters
$routes : array<string|int, mixed>
$file : string
$package : string|null = null
$optional : bool = false

							
On this page

Search results