final class Rewrite extends Router implements Route_Interface (View source)

For usage, please see the example section of \Yaf\Route\Rewrite::__construct()

Properties

protected Route_Interface[] $_routes from  Router
protected string $_current from  Router
protected string $_route
protected array $_default
protected array $_verify

Methods

__construct(string $match, array $route, array $verify = null, string $reverse = null)

No description

Router|false
addRoute(string $name, Route_Interface $route)

by default, \Yaf\Router using a \Yaf\Route_Static as its default route. you can add new routes into router's route stack by calling this method.


the newer route will be called before the older(route stack), and if the newer router return TRUE, the router process will be end. otherwise, the older one will be called.

from  Router
Router|false
addConfig(Config_Abstract $config)

Add routes defined by configs into \Yaf\Router's route stack

from  Router
Router|false
route(Request_Abstract $request)

No description

getRoute(string $name)

Retrieve a route by name, see also \Yaf\Router::getCurrentRoute()

from  Router
getRoutes()

No description

from  Router
string
getCurrentRoute()

Get the name of the route which is effective in the route process.


Note:

You should call this method after the route process finished, since before that, this method will always return NULL.

from  Router
bool
assemble(array $info, array $query = null)

\Yaf\Route\Rewrite::assemble() - Assemble a url

Details

__construct(string $match, array $route, array $verify = null, string $reverse = null)

No description

Parameters

string $match

A pattern, will be used to match a request uri, if doesn't matched, \Yaf\Route\Rewrite will return FALSE.

array $route

When the match pattern matches the request uri, \Yaf\Route\Rewrite will use this to decide which m/c/a to routed.


either of m/c/a in this array is optional, if you don't assign a specific value, it will be routed to default.

array $verify
string $reverse

Exceptions

TypeError

Router|false addRoute(string $name, Route_Interface $route)

by default, \Yaf\Router using a \Yaf\Route_Static as its default route. you can add new routes into router's route stack by calling this method.


the newer route will be called before the older(route stack), and if the newer router return TRUE, the router process will be end. otherwise, the older one will be called.

Parameters

string $name
Route_Interface $route

Return Value

Router|false

return FALSE on failure

Router|false addConfig(Config_Abstract $config)

Add routes defined by configs into \Yaf\Router's route stack

Parameters

Config_Abstract $config

Return Value

Router|false

return FALSE on failure

Router|false route(Request_Abstract $request)

No description

Parameters

Request_Abstract $request

Return Value

Router|false

return FALSE on failure

Route_Interface getRoute(string $name)

Retrieve a route by name, see also \Yaf\Router::getCurrentRoute()

Parameters

string $name

Return Value

Route_Interface

Route_Interface[] getRoutes()

No description

Return Value

Route_Interface[]

string getCurrentRoute()

Get the name of the route which is effective in the route process.


Note:

You should call this method after the route process finished, since before that, this method will always return NULL.

Return Value

string

the name of the effective route.

bool assemble(array $info, array $query = null)

\Yaf\Route\Rewrite::assemble() - Assemble a url

Parameters

array $info
array $query

Return Value

bool