final class Yaf_Route_Rewrite extends Yaf_Router implements Yaf_Route_Interface (View source)

For usage, please see the example section of Yaf_Route_Rewrite::__construct()

Properties

protected Yaf_Route_Interface[] $_routes from  Yaf_Router
protected string $_current from  Yaf_Router
protected string $_route
protected array $_default
protected array $_verify

Methods

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

No description

Yaf_Router|false
addRoute(string $name, Yaf_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.

Yaf_Router|false
addConfig(Yaf_Config_Abstract $config)

Add routes defined by configs into Yaf_Router's route stack

bool
route(Yaf_Request_Abstract $request)

No description

getRoute(string $name)

Retrieve a route by name, see also Yaf_Router::getCurrentRoute()

getRoutes()

No description

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.

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

Yaf_Route_Rewrite::assemble() - Assemble a url

bool
match(string $uri)

No description

Details

__construct(string $match, array $route, array $verify = null, string|null $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|null $reverse

Exceptions

Yaf_Exception_TypeError

Yaf_Router|false addRoute(string $name, Yaf_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
Yaf_Route_Interface $route

Return Value

Yaf_Router|false

return FALSE on failure

Yaf_Router|false addConfig(Yaf_Config_Abstract $config)

Add routes defined by configs into Yaf_Router's route stack

Parameters

Yaf_Config_Abstract $config

Return Value

Yaf_Router|false

return FALSE on failure

bool route(Yaf_Request_Abstract $request)

No description

Parameters

Yaf_Request_Abstract $request

Return Value

bool

Yaf_Route_Interface getRoute(string $name)

Retrieve a route by name, see also Yaf_Router::getCurrentRoute()

Parameters

string $name

Return Value

Yaf_Route_Interface

Yaf_Route_Interface[] getRoutes()

No description

Return Value

Yaf_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|null $query = null)

Yaf_Route_Rewrite::assemble() - Assemble a url

Parameters

array $info
array|null $query

Return Value

bool

bool match(string $uri)

No description

Parameters

string $uri

Return Value

bool