Documentation

Router
in package

Pop router class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2021 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
3.7.0

Table of Contents

$action  : mixed
Action
$controller  : mixed
Controller object
$controllerClass  : string
Controller class
$routeMatch  : MatchInterface
Route match object
__construct()  : mixed
Constructor
addControllerParams()  : Router
Add controller params to be passed into a new controller instance
addRoute()  : Router
Add a route
addRoutes()  : Router
Add multiple controller routes
appendControllerParams()  : Router
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()  : 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()  : Router
Prepare routes
removeControllerParams()  : Router
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 $controllerClass = null

Methods

__construct()

Constructor

public __construct([array<string|int, mixed> $routes = null ][, AbstractMatch $match = null ]) : mixed

Instantiate the router object

Parameters
$routes : array<string|int, mixed> = null
$match : AbstractMatch = null
Return values
mixed

addControllerParams()

Add controller params to be passed into a new controller instance

public addControllerParams(string $controller, mixed $params) : Router
Parameters
$controller : string
$params : mixed
Return values
Router

addRoute()

Add a route

public addRoute(string $route, mixed $controller) : Router
Parameters
$route : string
$controller : mixed
Return values
Router

addRoutes()

Add multiple controller routes

public addRoutes(array<string|int, mixed> $routes) : Router
Parameters
$routes : array<string|int, mixed>
Return values
Router

appendControllerParams()

Append controller params to be passed into a new controller instance

public appendControllerParams(string $controller, mixed $params) : Router
Parameters
$controller : string
$params : mixed
Return values
Router

getAction()

Get the action

public getAction() : mixed
Return values
mixed

getController()

Get the current controller object

public getController() : mixed
Return values
mixed

getControllerClass()

Get the current controller class name

public getControllerClass() : string
Return values
string

getControllerParams()

Get the params assigned to the controller

public getControllerParams(string $controller) : mixed
Parameters
$controller : string
Return values
mixed

getRouteParams()

Get the params discovered from the route

public getRouteParams() : mixed
Return values
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
throws
Exception
Return values
string

hasAction()

Determine if the router has an action

public hasAction() : bool
Return values
bool

hasController()

Determine if the router has a controller

public hasController() : bool
Return values
bool

hasControllerParams()

Determine if the controller has params

public hasControllerParams(string $controller) : bool
Parameters
$controller : string
Return values
bool

hasName()

Has a route name

public hasName(string $routeName) : bool
Parameters
$routeName : string
Return values
bool

hasRoute()

Determine if there is a route match

public hasRoute() : bool
Return values
bool

hasRouteParams()

Determine if the route has params

public hasRouteParams() : bool
Return values
bool

isCli()

Determine if the route is CLI

public isCli() : bool
Return values
bool

isHttp()

Determine if the route is HTTP

public isHttp() : bool
Return values
bool

name()

Add a route name

public name(string $routeName) : Router
Parameters
$routeName : string
Return values
Router

noRouteFound()

Method to process if a route was not found

public noRouteFound([bool $exit = true ]) : void
Parameters
$exit : bool = true
Return values
void

removeControllerParams()

Remove controller params

public removeControllerParams(string $controller) : Router
Parameters
$controller : string
Return values
Router

route()

Route to the correct controller

public route([string $forceRoute = null ]) : void
Parameters
$forceRoute : string = null
Tags
throws
Exception
throws
ReflectionException
Return values
void

Search results