Constants

METHOD_GET

METHOD_GET

METHOD_POST

METHOD_POST

METHOD_PUT

METHOD_PUT

METHOD_DELETE

METHOD_DELETE

Properties

$name

$name : string

A route is identified by its name

Type

string — The name

$path

$path : string

The path determine how to access this route

Type

string — The path

$controllerClass

$controllerClass : string

The class of called controller associated to this route

Type

string — The controller class

$options

$options : array

Non-processed options in route configuration

Type

array

$restrictTo

$restrictTo : array

Restrictions to access this route

Type

array

$routes

$routes : array

Registered routes

Type

array

$routesRestrictions

$routesRestrictions : array

Registered route restrictions

Type

array

$initialized

$initialized : string

Define this class initialized

Type

string

$resolverClass

$resolverClass : string

Class of the resolver

Type

string

$method

$method : string

The method to reach this route

Type

string

$pathRegex

$pathRegex : string

Path with converted regex

Type

string

$pathVariables

$pathVariables : array<mixed,string>

Variables in path

Type

array<mixed,string>

$typesRegex

$typesRegex : array

Registered regex for a type

Type

array

$outputResponses

$outputResponses : array

Registered response class for output option

Type

array

$knownMethods

$knownMethods : array

All known methods

Type

array

Methods

isMatchingRequest()

isMatchingRequest(\Orpheus\InputController\HTTPController\HTTPRequest  $request, array  $values = array(), boolean  $alternative = false) 

Test current route is matching request

Parameters

\Orpheus\InputController\HTTPController\HTTPRequest $request
array $values
boolean $alternative

True if we are looking for an alternative route, because we did not find any primary one

getRoutes()

getRoutes() : array

Get registered routes

Returns

array

registerConfig()

registerConfig(string  $name, array  $config) 

Register route by $name from config

Parameters

string $name
array $config

Throws

\Exception

initialize()

initialize() 

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

isInitialized()

isInitialized() : boolean

Test if the class is initialized

Returns

boolean

getName()

getName() : string

Get the name

Returns

string

getPath()

getPath() : string

Get the path

Returns

string

getControllerClass()

getControllerClass() : string

Get the controller class

Returns

string

getOptions()

getOptions() : array

Get route options

Returns

array

isAccessible()

isAccessible() : boolean

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

Returns

boolean

getLink()

getLink() : boolean

Get the link to this route

Returns

boolean

formatURL()

formatURL(array<mixed,string>  $values = array()) : string

Format the current route to get an URL from path

Parameters

array<mixed,string> $values

Throws

\Orpheus\InputController\HTTPController\Exception

Returns

string

registerAccessRestriction()

registerAccessRestriction(string  $type, callable  $callable) 

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

Parameters

string $type
callable $callable

getCurrentRouteName()

getCurrentRouteName() : \Orpheus\Core\srting

Get the current main route name

Throws

\Exception

Returns

\Orpheus\Core\srting

suggestResolver()

suggestResolver(string  $class) 

Suggest resolve $class

Parameters

string $class

setResolver()

setResolver(string  $class) 

Set the resolver class

Parameters

string $class

getRoute()

getRoute(string  $route, string  $method = null) : \Orpheus\InputController\HTTPController\HTTPRoute

Get the route object for the $route name

Parameters

string $route
string $method

Returns

\Orpheus\InputController\HTTPController\HTTPRoute

__toString()

__toString() : string

Get route as string

Returns

string

register()

register(string  $name, string  $path, string  $controller, string|array  $methods = null, array  $restrictTo = null, string  $defaultResponse, array  $options = array()) 

Register route by $name

Parameters

string $name
string $path
string $controller
string|array $methods
array $restrictTo
string $defaultResponse
array $options

getOutputResponse()

getOutputResponse(string  $output) : mixed

Get the output response

Parameters

string $output

Returns

mixed

setOutputResponse()

setOutputResponse(string  $output, string  $responseClass) 

Set the output response

Parameters

string $output
string $responseClass

setTypeRegex()

setTypeRegex(string  $type, string  $regex) 

Set the regex of a type, used to parse paths

Parameters

string $type
string $regex

getKnownMethods()

getKnownMethods() : array<mixed,string>

Get the known HTTP methods

Returns

array<mixed,string>

__construct()

__construct(string  $name, string  $path, string  $controller, string  $method, array  $restrictTo, string  $defaultResponse, array  $options) 

Constructor

Parameters

string $name
string $path
string $controller
string $method
array $restrictTo
string $defaultResponse
array $options

extractVariable()

extractVariable(string  $str, string  $var = null, string  $regex = null) 

Extract variable from configuration string

Parameters

string $str
string $var
string $regex

generatePathRegex()

generatePathRegex() 

Generate all regex of the path from extracted variables