(Yaf >=1.0.0)
Yaf_Router::addRoute — 锟斤拷Router锟斤拷锟斤拷锟斤拷碌锟铰凤拷锟�
默锟较地o拷Yaf_Router使锟斤拷Yaf_Route_Static锟斤拷为锟斤拷锟斤拷默锟较碉拷路锟缴★拷锟斤拷锟斤拷锟酵拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷Router锟侥讹拷栈锟斤拷锟斤拷锟揭伙拷锟斤拷碌锟铰凤拷锟�
锟斤拷路锟斤拷栈锟叫o拷锟铰碉拷路锟缴癸拷锟斤拷锟斤拷锟较的癸拷锟斤拷锟饺碉拷锟矫o拷锟斤拷锟斤拷锟铰凤拷晒锟斤拷蚍祷锟絋RUE锟斤拷锟斤拷么路锟缴斤拷锟教斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷系墓锟斤拷蚪岜伙拷锟斤拷谩锟�
锟斤拷锟斤拷锟斤拷锟斤拷未锟斤拷写锟侥碉拷锟斤拷锟斤拷锟叫诧拷锟斤拷锟叫憋拷
锟剿猴拷锟斤拷没锟叫诧拷锟斤拷锟斤拷
Example #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);
}
?>