Router
in package
Pop router class
Tags
Table of Contents
Properties
- $action : mixed
- Action
- $controller : mixed
- Controller object
- $controllerClass : string|null
- Controller class
- $routeMatch : MatchInterface|null
- Route match object
Methods
- __construct() : mixed
- Constructor
- addControllerParams() : static
- Add controller params to be passed into a new controller instance
- addRoute() : static
- Add a route
- addRoutes() : static
- Add multiple controller routes
- appendControllerParams() : static
- Append controller params to be passed into a new controller instance
- getAction() : mixed
- Get the action
- getController() : mixed
- Get the current controller object
- getControllerClass() : string
- Get the current controller class name
- getControllerParams() : mixed
- Get the params assigned to the controller
- getRouteMatch() : MatchInterface
- Get route match object
- getRouteParams() : array<string|int, mixed>
- Get the params discovered from the route
- getRoutes() : array<string|int, mixed>
- Get routes
- getUrl() : string
- Get URL for the named route
- hasAction() : bool
- Determine if the router has an action
- hasController() : bool
- Determine if the router has a controller
- hasControllerParams() : bool
- Determine if the controller has params
- hasName() : bool
- Has a route name
- hasRoute() : bool
- Determine if there is a route match
- hasRouteParams() : bool
- Determine if the route has params
- isCli() : bool
- Determine if the route is CLI
- isHttp() : bool
- Determine if the route is HTTP
- name() : Router
- Add a route name
- noRouteFound() : void
- Method to process if a route was not found
- prepare() : static
- Prepare routes
- removeControllerParams() : static
- Remove controller params
- route() : void
- Route to the correct controller
Properties
$action
Action
protected
mixed
$action
= null
$controller
Controller object
protected
mixed
$controller
= null
$controllerClass
Controller class
protected
string|null
$controllerClass
= null
$routeMatch
Route match object
protected
MatchInterface|null
$routeMatch
= null
Methods
__construct()
Constructor
public
__construct([array<string|int, mixed>|null $routes = null ][, AbstractMatch|null $match = null ]) : mixed
Instantiate the router object
Parameters
- $routes : array<string|int, mixed>|null = null
- $match : AbstractMatch|null = null
addControllerParams()
Add controller params to be passed into a new controller instance
public
addControllerParams(string $controller, mixed $params) : static
Parameters
- $controller : string
- $params : mixed
Return values
staticaddRoute()
Add a route
public
addRoute(string $route, mixed $controller) : static
Parameters
- $route : string
- $controller : mixed
Return values
staticaddRoutes()
Add multiple controller routes
public
addRoutes(array<string|int, mixed> $routes) : static
Parameters
- $routes : array<string|int, mixed>
Return values
staticappendControllerParams()
Append controller params to be passed into a new controller instance
public
appendControllerParams(string $controller, mixed $params) : static
Parameters
- $controller : string
- $params : mixed
Return values
staticgetAction()
Get the action
public
getAction() : mixed
getController()
Get the current controller object
public
getController() : mixed
getControllerClass()
Get the current controller class name
public
getControllerClass() : string
Return values
stringgetControllerParams()
Get the params assigned to the controller
public
getControllerParams(string $controller) : mixed
Parameters
- $controller : string
getRouteMatch()
Get route match object
public
getRouteMatch() : MatchInterface
Return values
MatchInterfacegetRouteParams()
Get the params discovered from the route
public
getRouteParams() : array<string|int, mixed>
Return values
array<string|int, mixed>getRoutes()
Get routes
public
getRoutes() : array<string|int, mixed>
Return values
array<string|int, mixed>getUrl()
Get URL for the named route
public
getUrl(string $routeName[, mixed $params = null ][, bool $fqdn = false ]) : string
Parameters
- $routeName : string
- $params : mixed = null
- $fqdn : bool = false
Tags
Return values
stringhasAction()
Determine if the router has an action
public
hasAction() : bool
Return values
boolhasController()
Determine if the router has a controller
public
hasController() : bool
Return values
boolhasControllerParams()
Determine if the controller has params
public
hasControllerParams(string $controller) : bool
Parameters
- $controller : string
Return values
boolhasName()
Has a route name
public
hasName(string $routeName) : bool
Parameters
- $routeName : string
Return values
boolhasRoute()
Determine if there is a route match
public
hasRoute() : bool
Return values
boolhasRouteParams()
Determine if the route has params
public
hasRouteParams() : bool
Return values
boolisCli()
Determine if the route is CLI
public
isCli() : bool
Return values
boolisHttp()
Determine if the route is HTTP
public
isHttp() : bool
Return values
boolname()
Add a route name
public
name(string $routeName) : Router
Parameters
- $routeName : string
Return values
RouternoRouteFound()
Method to process if a route was not found
public
noRouteFound([bool $exit = true ]) : void
Parameters
- $exit : bool = true
prepare()
Prepare routes
public
prepare() : static
Return values
staticremoveControllerParams()
Remove controller params
public
removeControllerParams(string $controller) : static
Parameters
- $controller : string
Return values
staticroute()
Route to the correct controller
public
route([string|null $forceRoute = null ]) : void
Parameters
- $forceRoute : string|null = null