diff --git a/reference/yaf/yaf-route-simple.xml b/reference/yaf/yaf-route-simple.xml index 4bc6c55950..6c243e5367 100644 --- a/reference/yaf/yaf-route-simple.xml +++ b/reference/yaf/yaf-route-simple.xml @@ -12,7 +12,17 @@
&reftitle.intro; - + Yaf_Route_Simple will match the query string, and + find the route info. + + + all you need to do is tell Yaf_Route_Simple what key in the $_GET is + module, what key is controller, and what key is action. + + + Yaf_Route_Simple::route will always return TRUE, + so it is important put Yaf_Route_Simple in the front of the Route stack, + otherwise all the other routes will not be called.
diff --git a/reference/yaf/yaf-route-static.xml b/reference/yaf/yaf-route-static.xml index 4c80292f60..be64ee7e69 100644 --- a/reference/yaf/yaf-route-static.xml +++ b/reference/yaf/yaf-route-static.xml @@ -12,7 +12,12 @@
&reftitle.intro; - + Defaultly, Yaf_Router only have a + Yaf_Route_Static as its default route. + + + And Yaf_Route_Static is designed to handle the + 80% requirement.
diff --git a/reference/yaf/yaf_action_abstract/execute.xml b/reference/yaf/yaf_action_abstract/execute.xml index 071d280ccc..db7fb6e837 100644 --- a/reference/yaf/yaf_action_abstract/execute.xml +++ b/reference/yaf/yaf_action_abstract/execute.xml @@ -4,7 +4,7 @@ Yaf_Action_Abstract::execute - entry point method + Execute the action diff --git a/reference/yaf/yaf_application/construct.xml b/reference/yaf/yaf_application/construct.xml index 9aebc1048b..97d68c9c1b 100644 --- a/reference/yaf/yaf_application/construct.xml +++ b/reference/yaf/yaf_application/construct.xml @@ -83,7 +83,7 @@ $config = array( ), ); -/** Ap_Application */ +/** Yaf_Application */ $application = new Yaf_Application($config); $application->bootstrap()->run(); ?> diff --git a/reference/yaf/yaf_application/environ.xml b/reference/yaf/yaf_application/environ.xml index 76f145d24b..635f2ec3a1 100644 --- a/reference/yaf/yaf_application/environ.xml +++ b/reference/yaf/yaf_application/environ.xml @@ -47,7 +47,7 @@ $config = array( ), ); -/** Ap_Application */ +/** Yaf_Application */ $application = new Yaf_Application($config); print_r($application->environ()); ?> diff --git a/reference/yaf/yaf_application/execute.xml b/reference/yaf/yaf_application/execute.xml index b4ea5959ae..58c978beb9 100644 --- a/reference/yaf/yaf_application/execute.xml +++ b/reference/yaf/yaf_application/execute.xml @@ -68,7 +68,7 @@ $config = array( ), ); -/** Ap_Application */ +/** Yaf_Application */ $application = new Yaf_Application($config); $application->execute("main", $argc, $argv); ?> diff --git a/reference/yaf/yaf_application/getconfig.xml b/reference/yaf/yaf_application/getconfig.xml index 0cb30be824..69de760ea5 100644 --- a/reference/yaf/yaf_application/getconfig.xml +++ b/reference/yaf/yaf_application/getconfig.xml @@ -46,7 +46,7 @@ $config = array( ), ); -/** Ap_Application */ +/** Yaf_Application */ $application = new Yaf_Application($config); print_r($application->getConfig()); ?> diff --git a/reference/yaf/yaf_application/getdispatcher.xml b/reference/yaf/yaf_application/getdispatcher.xml index 9a0741dc9f..19cc095b3a 100644 --- a/reference/yaf/yaf_application/getdispatcher.xml +++ b/reference/yaf/yaf_application/getdispatcher.xml @@ -46,7 +46,7 @@ $config = array( ), ); -/** Ap_Application */ +/** Yaf_Application */ $application = new Yaf_Application($config); print_r($application->getDispatcher()); ?> diff --git a/reference/yaf/yaf_application/getmodules.xml b/reference/yaf/yaf_application/getmodules.xml index 60552bcd28..f55e28e624 100644 --- a/reference/yaf/yaf_application/getmodules.xml +++ b/reference/yaf/yaf_application/getmodules.xml @@ -47,7 +47,7 @@ $config = array( ), ); -/** Ap_Application */ +/** Yaf_Application */ $application = new Yaf_Application($config); print_r($application->getModules()); ?> diff --git a/reference/yaf/yaf_dispatcher/catchexception.xml b/reference/yaf/yaf_dispatcher/catchexception.xml index deea10bee3..b9b5899e2f 100644 --- a/reference/yaf/yaf_dispatcher/catchexception.xml +++ b/reference/yaf/yaf_dispatcher/catchexception.xml @@ -14,7 +14,14 @@ boolflag - + While the application.dispatcher.throwException is On(you can also calling + to Yaf_Dispatcher::throwException(TRUE) to enable it), Yaf will throw Exception whe + error occurrs instead of trigger error. + + + then if you enable Yaf_Dispatcher::catchException(also can enabled by set + application.dispatcher.catchException), all Un-caught Exceptions will be + caught by ErrorController::error if you have defined one. &warn.undocumented.func; @@ -28,7 +35,7 @@ flag - + @@ -42,6 +49,53 @@ + + &reftitle.examples; + + <function>Yaf_Dispatcher::catchException</function>example + +getCode()) { + case YAF_ERR_NOTFOUND_MODULE: + case YAF_ERR_NOTFOUND_CONTROLLER: + case YAF_ERR_NOTFOUND_ACTION: + case YAF_ERR_NOTFOUND_VIEW: + echo 404, ":", $exception->getMessage(); + break; + default : + $message = $exception->getMessage(); + echo 0, ":", $exception->getMessage(); + break; + } + } +} +?> +]]> + + &example.outputs.similar; + + + + + + + &reftitle.seealso; + + Yaf_Dispatcher::throwException + + diff --git a/reference/yaf/yaf_router/addconfig.xml b/reference/yaf/yaf_router/addconfig.xml index 2dcf9c93d3..035909b905 100644 --- a/reference/yaf/yaf_router/addconfig.xml +++ b/reference/yaf/yaf_router/addconfig.xml @@ -4,7 +4,7 @@ Yaf_Router::addConfig - The addConfig purpose + Add config-defined routes into Router @@ -14,7 +14,8 @@ Yaf_Config_Abstractconfig - + Add Routes defined in application.ini into + Yaf_Router's route stack &warn.undocumented.func; @@ -33,6 +34,76 @@ + + &reftitle.examples; + + <function>application.ini</function>example + + + + + + <function>Yaf_Dispatcher::autoConfig</function>example + +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); + } +?> +]]> + + + + + + &reftitle.seealso; + + Yaf_Router::addRoute + Yaf_Route_Static + Yaf_Route_Supervar + Yaf_Route_Simple + Yaf_Route_Regex + Yaf_Route_Rewrite + Yaf_Route_Map + + diff --git a/reference/yaf/yaf_router/addroute.xml b/reference/yaf/yaf_router/addroute.xml index 8a751472b5..5e1f3de047 100644 --- a/reference/yaf/yaf_router/addroute.xml +++ b/reference/yaf/yaf_router/addroute.xml @@ -4,7 +4,7 @@ Yaf_Router::addRoute - The addRoute purpose + Add new Route into Router @@ -15,7 +15,13 @@ Yaf_Route_Abstractroute - + 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. &warn.undocumented.func; @@ -34,6 +40,69 @@ + + &reftitle.examples; + + <function>Yaf_Dispatcher::autoRender</function>example + +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); + } +?> +]]> + + + + + + &reftitle.seealso; + + Yaf_Router::addConfig + Yaf_Route_Static + Yaf_Route_Supervar + Yaf_Route_Simple + Yaf_Route_Regex + Yaf_Route_Rewrite + Yaf_Route_Map + +