Documentation

Router
in package

Pop router class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

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

license

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

version
4.2.0

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

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
static

addRoute()

Add a route

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

addRoutes()

Add multiple controller routes

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

appendControllerParams()

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
static

getAction()

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
string

getControllerParams()

Get the params assigned to the controller

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

getRouteParams()

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
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

prepare()

Prepare routes

public prepare() : static
Return values
static

removeControllerParams()

Remove controller params

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

route()

Route to the correct controller

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

        
On this page

Search results