(Yaf >=1.0.0)
Yaf_Router::addRoute — 往Router中添加新的路由
默認(rèn)地,Yaf_Router使用Yaf_Route_Static作為它的默認(rèn)的路由。你可以通過(guò)調(diào)用這個(gè)方法往Router的堆棧中添加一個(gè)新的路由
在路由棧中,新的路由規(guī)則會(huì)比老的規(guī)則先調(diào)用,如果新路由規(guī)則返回TRUE,那么路由進(jìn)程將會(huì)結(jié)束。否則,老的規(guī)則將會(huì)被調(diào)用。
本函數(shù)還未編寫(xiě)文檔,僅有參數(shù)列表。
此函數(shù)沒(méi)有參數(shù)。
示例 #1 Yaf_Dispatcher::autoRender()example
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract{
public function _initConfig() {
$config = Yaf_Application::app()->getConfig();
Yaf_Registry::set("config", $config);
}
public function _initRoute(Yaf_Dispatcher $dispatcher) {
$router = $dispatcher->getRouter();
/**
* we can add some pre-defined routes in application.ini
*/
$router->addConfig(Yaf_Registry::get("config")->routes);
/**
* add a Rewrite route, then for a request uri:
* http://***/product/list/22/foo
* will be matched by this route, and result:
*
* [module] =>
* [controller] => product
* [action] => info
* [method] => GET
* [params:protected] => Array
* (
* [id] => 22
* [name] => foo
* )
*
*/
$route = new Yaf_Route_Rewrite(
"/product/list/:id/:name",
array(
"controller" => "product",
"action" => "info",
)
);
$router->addRoute('dummy', $route);
}
?>