CliRoute
extends ControllerRoute
in package
Route for Orpheus.
Table of Contents
Constants
- 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
- $name : string
- A route is identified by its name
- $options : array<string|int, mixed>
- Non-processed options in route configuration
- $path : string
- The path determine how to access this route
- $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
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
- getLink() : string
- Get the link to this route
- getName() : string
- Get the name
- getOptions() : array<string|int, mixed>
- Get route options
- getPath() : string
- Get the path
- getRootCommand() : string
- getRoute() : CliRoute
- Get the route object for the $route name
- getRoutes() : array<string|int, ControllerRoute>
- Get registered routes
- 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
- 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
- __construct() : mixed
- Constructor
- 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
PROVIDERS_KEY
public
mixed
PROVIDERS_KEY
= 'providers'
REQUIREMENTS_KEY
public
mixed
REQUIREMENTS_KEY
= 'require-packages'
Properties
$controller
The running controller
protected
AbstractController
$controller
$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
$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
$path
The path determine how to access this route
protected
string
$path
The path
$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
= []
Methods
__toString()
Get route as string
public
__toString() : string
Return values
stringformatUrl()
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
stringgetController()
public
getController() : AbstractController
Return values
AbstractControllergetControllerClass()
Get the controller class
public
getControllerClass() : string
Return values
stringgetCurrentRouteName()
Get the current route name
public
static getCurrentRouteName() : string
Return values
stringgetLink()
Get the link to this route
public
abstract getLink() : string
Return values
stringgetName()
Get the name
public
abstract getName() : string
Return values
stringgetOptions()
Get route options
public
getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>getPath()
Get the path
public
getPath() : string
Return values
stringgetRootCommand()
public
static getRootCommand() : string
Return values
stringgetRoute()
Get the route object for the $route name
public
static getRoute(string $name) : CliRoute
Parameters
- $name : string
Return values
CliRoutegetRoutes()
Get registered routes
public
static getRoutes() : array<string|int, ControllerRoute>
Return values
array<string|int, ControllerRoute>initialize()
Initialize the route class by loading the configuration (once only)
public
static initialize() : void
instantiateController()
Instantiate the controller and return it
public
instantiateController() : AbstractController
Return values
AbstractControllerisAccessible()
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
boolisInitialized()
Test if the class is initialized
public
static isInitialized() : bool
Return values
boolisMatchingRequest()
Test current route is matching request
public
isMatchingRequest(CliRequest $request[, array<string|int, mixed> &$values = [] ][, bool $alternative = false ]) : bool
Parameters
- $request : CliRequest
- $values : array<string|int, mixed> = []
- $alternative : bool = false
Tags
Return values
boolregister()
Register route by $name
public
static register(string $name, string $path, string $controller, array<string|int, mixed> $parameters[, array<string|int, mixed> $options = [] ]) : void
Parameters
- $name : string
- $path : string
- $controller : string
- $parameters : array<string|int, mixed>
- $options : array<string|int, mixed> = []
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
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
run()
Run the $request by processing the matching controller
public
run(InputRequest $request) : OutputResponse
Parameters
- $request : InputRequest
Tags
Return values
OutputResponse__construct()
Constructor
protected
__construct(string $name, string $path, string $controller, array<string|int, string> $parameters, array<string|int, mixed> $options) : mixed
Parameters
- $name : string
- $path : string
- $controller : string
- $parameters : array<string|int, string>
- $options : array<string|int, mixed>
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