Yaf_Router::addRoute

(Yaf >=1.0.0)

Yaf_Router::addRouteAdd new Route into Router

Description

publicYaf_Router::addRoute(string$name, Yaf_Route_Abstract$route): bool

defaultly, Yaf_Router using a Yaf_Route_Static as its defualt 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

This function has no parameters.

Return Values

Examples

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();

$router->addConfig(Yaf_Registry::get("config")->routes);

$route = new Yaf_Route_Rewrite(
"/product/list/:id/:name",
array(
"controller" => "product",
"action" => "info",
)
);

$router->addRoute('dummy', $route);
}
}
?>
To Top