Приклад #1 Custom routes
Besides the default Yaf_Route_Static route,
custom routes can be registered on the
Yaf_Router route stack, usually in a
_initRoute method of the Bootstrap, using
Yaf_Router::addRoute(). Routes can also be
declared in configuration files and loaded with
Yaf_Router::addConfig().
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract
{
public function _initRoute(Yaf_Dispatcher $dispatcher)
{
$router = $dispatcher->getRouter();
// /user/123 -> controller=user, action=index, id=123
$router->addRoute("user", new Yaf_Route_Rewrite(
"/user/:id",
array("controller" => "user", "action" => "index")
));
}
}
?>