Documentation

RoutesSetBase

Trait RoutesSetBase

Tags
author

Dodonov A.A.

version

v.1.0 (2021/09/27)

copyright

Copyright (c) 2021, http://aeon.su

Table of Contents

$routeNames  : array<string|int, string>
Route names
addGetRoute()  : void
Additing route for GET request
addPostRoute()  : void
Additing route for GET request
addRoute()  : void
Method adds route and it's handler
clear()  : void
Method clears router data
getRouteByName()  : string
Getting route by name
reverse()  : string
Compiling route into URL
routeExists()  : bool
Method returns true if the router exists
clearMiddleware()  : void
Method clears middleware
clearOtherData()  : void
Method clears other data
paramRouteExists()  : bool
Method returns true if the param router exists
registerRouteName()  : void
Method registers name of the route
routeNameExists()  : bool
Validating that route name exists

Properties

$routeNames

Route names

private array<string|int, string> $routeNames = []

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

clear()

Method clears router data

public clear() : void
Return values
void

getRouteByName()

Getting route by name

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

route's name

Return values
string

route

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

clearMiddleware()

Method clears middleware

protected abstract clearMiddleware() : void
Return values
void

clearOtherData()

Method clears other data

protected clearOtherData() : void
Return values
void

paramRouteExists()

Method returns true if the param router exists

protected abstract paramRouteExists(string $route, string $requestMethod) : bool
Parameters
$route : string

checking route

$requestMethod : string

HTTP request method

Return values
bool

true if the param router exists, false otherwise

registerRouteName()

Method registers name of the route

protected registerRouteName(string $routeName, string $route) : void
Parameters
$routeName : string

route's name

$route : string

route

Return values
void

routeNameExists()

Validating that route name exists

protected routeNameExists(string $routeName) : bool
Parameters
$routeName : string

route name

Return values
bool

true if the route exists, false otherwise

Search results