class Routes implements RoutesInterface

Routes storage

Properties

protected RoutesStorageInterface $adapter Routes storage adapter
protected CacheInterface $cache Cache

Methods

__construct(RoutesStorageInterface $adapter, CacheInterface $cache)

Constructor

bool
addMiddleware(string $method, string $pattern, string $middlewareClass)

Add route middleware

bool
setRoutesStatus(array $filter = [], int $status)

Set routes status

bool
setRedirectUrl(string $method, string $pattern, string $url)

Save route redirect url

bool
saveTemplateRoute(string $pattern, string $handlerClass, string|null $handlerMethod, string $templateName, string|null $pageName, integer|null $auth = null, bool $replace = false, string|null $redirectUrl = null, int $type = RoutesInterface::PAGE, bool $withLanguage = true)

Add template route

bool
addHomePageRoute(string $pattern, string $handlerClass, string $handlerMethod, string|null $extension, string $pageName, integer $auth = null, string|null $name = null, bool $withLanguage = true)

Add home page route

bool
addPageRoute(string $pattern, string $handlerClass, string $handlerMethod, string $extension, string|null $pageName, string|null $auth = null, string|null $name = null, bool $withLanguage = true, integer $type = RoutesInterface::PAGE)

Add page route

string
getLanguagePattern(string $pattern)

Get language pattern

bool
addApiRoute(string $method, string $pattern, string $handlerClass, string|null $handlerMethod, string|null $extension, string|null $auth = null, int $type = RoutesInterface::API)

Add api route

bool
has(string $method, string $pattern)

Return true if reoute exists

bool
delete(string $method, string $pattern)

Delete route

bool
saveRouteOptions(string $method, string $pattern, array $options)

Save route options

bool
deleteHomePage()

Delete home page route

bool
deleteRoutes($filter = [])

Delete routes

array|false
getRoute(string $method, string $pattern)

Get route

array|null
getRouteDetails(string|int $id)

Get route details

array
getRoutes(array $filter = [])

Get routes

array
getAllRoutes()

Get all actve routes from storage

array
searchRoutes(string $method, $type = null)

Get routes list for request method

array
getHomePageRoute()

Get home page route

Details

at line 44
__construct(RoutesStorageInterface $adapter, CacheInterface $cache)

Constructor

Parameters

RoutesStorageInterface $adapter
CacheInterface $cache

at line 58
bool addMiddleware(string $method, string $pattern, string $middlewareClass)

Add route middleware

Parameters

string $method
string $pattern
string $middlewareClass

Return Value

bool

at line 70
bool setRoutesStatus(array $filter = [], int $status)

Set routes status

Parameters

array $filter
int $status

Return Value

bool

at line 83
bool setRedirectUrl(string $method, string $pattern, string $url)

Save route redirect url

Parameters

string $method
string $pattern
string $url

Return Value

bool

at line 103
bool saveTemplateRoute(string $pattern, string $handlerClass, string|null $handlerMethod, string $templateName, string|null $pageName, integer|null $auth = null, bool $replace = false, string|null $redirectUrl = null, int $type = RoutesInterface::PAGE, bool $withLanguage = true)

Add template route

Parameters

string $pattern
string $handlerClass
string|null $handlerMethod
string $templateName
string|null $pageName
integer|null $auth
bool $replace
string|null $redirectUrl
int $type
bool $withLanguage

Return Value

bool

at line 176
bool addHomePageRoute(string $pattern, string $handlerClass, string $handlerMethod, string|null $extension, string $pageName, integer $auth = null, string|null $name = null, bool $withLanguage = true)

Add home page route

Parameters

string $pattern
string $handlerClass
string $handlerMethod
string|null $extension
string $pageName
integer $auth
string|null $name
bool $withLanguage

Return Value

bool

at line 214
bool addPageRoute(string $pattern, string $handlerClass, string $handlerMethod, string $extension, string|null $pageName, string|null $auth = null, string|null $name = null, bool $withLanguage = true, integer $type = RoutesInterface::PAGE)

Add page route

Parameters

string $pattern
string $handlerClass
string $handlerMethod
string $extension
string|null $pageName
string|null $auth
string|null $name
bool $withLanguage
integer $type

Return Value

bool

at line 268
string getLanguagePattern(string $pattern)

Get language pattern

Parameters

string $pattern

Return Value

string

at line 286
bool addApiRoute(string $method, string $pattern, string $handlerClass, string|null $handlerMethod, string|null $extension, string|null $auth = null, int $type = RoutesInterface::API)

Add api route

Parameters

string $method
string $pattern
string $handlerClass
string|null $handlerMethod
string|null $extension
string|null $auth
int $type

Return Value

bool

Exceptions

Exception

at line 331
bool has(string $method, string $pattern)

Return true if reoute exists

Parameters

string $method
string $pattern

Return Value

bool

at line 343
bool delete(string $method, string $pattern)

Delete route

Parameters

string $method
string $pattern

Return Value

bool

at line 356
bool saveRouteOptions(string $method, string $pattern, array $options)

Save route options

Parameters

string $method
string $pattern
array $options

Return Value

bool

at line 366
bool deleteHomePage()

Delete home page route

Return Value

bool

at line 377
bool deleteRoutes($filter = [])

Delete routes

Parameters

$filter

Return Value

bool

at line 389
array|false getRoute(string $method, string $pattern)

Get route

Parameters

string $method
string $pattern

Return Value

array|false

at line 400
array|null getRouteDetails(string|int $id)

Get route details

Parameters

string|int $id Route id or uuid

Return Value

array|null

at line 411
array getRoutes(array $filter = [])

Get routes

Parameters

array $filter

Return Value

array

at line 421
array getAllRoutes()

Get all actve routes from storage

Return Value

array

at line 439
array searchRoutes(string $method, $type = null)

Get routes list for request method

Parameters

string $method
$type

Return Value

array

at line 456
array getHomePageRoute()

Get home page route

Return Value

array