Documentation

RouterInterface
in

Router interface

Table of Contents

addGetRoute()  : void
Additing route for GET request
addPostRoute()  : void
Additing route for GET request
addRoute()  : void
Method adds route and it's handler
addType()  : void
Method adds custom type
callRoute()  : mixed
Processing specified router
clear()  : void
Method clears router data
getParam()  : mixed
Method returns route parameter
getRouteByName()  : string
Getting route by name
hasParam()  : bool
Does parameter exists
registerMiddleware()  : void
Method registeres middleware for the router
reverse()  : string
Compiling route into URL
routeExists()  : bool
Method returns true if the router exists
setNoProcessorFoundErrorHandler()  : callable|null
Method sets InvalidRouteErrorHandler function

Methods

addGetRoute()

Additing route for GET request

public addGetRoute(string $route, object $object, string $method) : void
Parameters
$route : string

route

$object : object

callback object

$method : string

callback method

Return values
void

addPostRoute()

Additing route for GET request

public addPostRoute(string $route, object $object, string $method) : void
Parameters
$route : string

route

$object : object

callback object

$method : string

callback method

Return values
void

addRoute()

Method adds route and it's handler

public addRoute(string $route, mixed $callback[, string|array<string|int, string> $requestMethod = 'GET' ][, string $routeName = '' ]) : void

$callback function may have two parameters - $route and $parameters. Where $route is a called route, and $parameters is associative array (parameter name => parameter value) with URL parameters

Parameters
$route : string

route

$callback : mixed
$requestMethod : string|array<string|int, string> = 'GET'

request type

$routeName : string = ''

name of the route

Return values
void

addType()

Method adds custom type

public addType(string $typeName, string $className) : void
Parameters
$typeName : string

type name

$className : string

name of the class wich represents custom type

Return values
void

callRoute()

Processing specified router

public callRoute(array<string|int, string>|string $route) : mixed
Parameters
$route : array<string|int, string>|string

route

Return values
mixed

value returned by route handler

clear()

Method clears router data

public clear() : void
Return values
void

getParam()

Method returns route parameter

public getParam(string $name) : mixed
Parameters
$name : string

route parameter

Return values
mixed

route parameter

getRouteByName()

Getting route by name

public getRouteByName(string $routeName) : string
Parameters
$routeName : string

route's name

Return values
string

route

hasParam()

Does parameter exists

public hasParam(string $name) : bool
Parameters
$name : string

param name

Return values
bool

true if the parameter exists

registerMiddleware()

Method registeres middleware for the router

public registerMiddleware(string $router, callable $middleware) : void
Parameters
$router : string
$middleware : callable

middleware

Return values
void

reverse()

Compiling route into URL

public reverse(string $routeName[, array<string|int, string> $parameters = [] ]) : string
Parameters
$routeName : string

route name

$parameters : array<string|int, string> = []

parameters to use in URL

Return values
string

compiled route

routeExists()

Method returns true if the router exists

public routeExists(string $route) : bool
Parameters
$route : string

checking route

Return values
bool

true if the router exists, false otherwise

setNoProcessorFoundErrorHandler()

Method sets InvalidRouteErrorHandler function

public setNoProcessorFoundErrorHandler(callable $function) : callable|null
Parameters
$function : callable

error handler

Return values
callable|null

old error handler

Search results

    Яндекс.Метрика