From 702e372f6cc608578f1c3de513df94174e64bf48 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Mon, 28 Nov 2011 04:55:20 +0000 Subject: [PATCH] update docs git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@320070 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/yaf/yaf-route-regex.xml | 3 +- reference/yaf/yaf_route_regex/construct.xml | 81 ++++++++++++- reference/yaf/yaf_route_rewrite/construct.xml | 112 +++++++++++++++++- 3 files changed, 189 insertions(+), 7 deletions(-) diff --git a/reference/yaf/yaf-route-regex.xml b/reference/yaf/yaf-route-regex.xml index be543541a8..6f401da6fa 100644 --- a/reference/yaf/yaf-route-regex.xml +++ b/reference/yaf/yaf-route-regex.xml @@ -12,7 +12,8 @@
&reftitle.intro; - + Yaf_Route_Regex is the most flexible route among + the Yaf built-in routes.
diff --git a/reference/yaf/yaf_route_regex/construct.xml b/reference/yaf/yaf_route_regex/construct.xml index e3e03f3de7..df4392ee65 100644 --- a/reference/yaf/yaf_route_regex/construct.xml +++ b/reference/yaf/yaf_route_regex/construct.xml @@ -17,7 +17,7 @@ arrayverify - + &warn.undocumented.func; @@ -31,7 +31,9 @@ match - + A complete Regex pattern, will be used to match a request uri, if + doesn't matched, Yaf_Route_Regex will return + FALSE. @@ -39,7 +41,13 @@ route - + When the match pattern matches the request uri, + Yaf_Route_Regex will use this to decide which + m/c/a to routed. + + + either of m/c/a in this array is optianl, if you don't assgian a + specific value, it will be routed to default. @@ -47,7 +55,7 @@ map - + A array to assign name to the captrues in the match result. @@ -69,6 +77,71 @@ + + &reftitle.examples; + + <function>Yaf_Route_Regex</function>example + +getRouter()->addRoute("name", + new Yaf_Route_Regex( + "#^/product/([^/]+)/([^/])+#", //match request uri leading "/product" + array( + 'controller' => "product", //route to product controller, + ), + array( + 1 => "name", // now you can call $request->getParam("name") + 2 => "id", // to get the first captrue in the match pattern. + ) + ) + ); +]]> + + + + <function>Yaf_Route_Regex</function>example + + array( + "type" => "regex", //Yaf_Route_Regex route + "match" => "#(.*)#", //match arbitrary request uri + "route" => array( + 'controller' => "product", //route to product controller, + 'action' => "dummy", //route to dummy action + ), + "map" => array( + 1 => "uri", // now you can call $request->getParam("uri") + ), + ), + ); + Yaf_Dispatcher::getInstance()->getRouter()->addConfig( + new Yaf_Config_Simple($config)); +]]> + + + + + + &reftitle.seealso; + + Yaf_Router::addRoute + Yaf_Router::addConfig + Yaf_Route_Static + Yaf_Route_Supervar + Yaf_Route_Simple + Yaf_Route_Rewrite + Yaf_Route_Map + + diff --git a/reference/yaf/yaf_route_rewrite/construct.xml b/reference/yaf/yaf_route_rewrite/construct.xml index 4dc7284c53..e53d6148d8 100644 --- a/reference/yaf/yaf_route_rewrite/construct.xml +++ b/reference/yaf/yaf_route_rewrite/construct.xml @@ -30,7 +30,9 @@ match - + A pattern, will be used to match a request uri, if + doesn't matched, Yaf_Route_Rewrite will return + FALSE. @@ -38,7 +40,13 @@ route - + When the match pattern matches the request uri, + Yaf_Route_Rewrite will use this to decide which + m/c/a to routed. + + + either of m/c/a in this array is optianl, if you don't assgian a + specific value, it will be routed to default. @@ -60,6 +68,106 @@ + + &reftitle.examples; + + <function>Yaf_Route_Rewrite</function>example + +getRouter()->addRoute("name", + new Yaf_Route_rewrite( + "/product/:name/:id/*", //match request uri leading "/product" + array( + 'controller' => "product", //route to product controller, + ), + ) + ); +]]> + + &example.outputs.similar; + + "product", + "module" => "index", //(default) + "action" => "index", //(default) +) + +/** + * and request parameters: + */ +array( + "name" => "foo", + "id" => 22, + "foo" => bar +) +]]> + + + + <function>Yaf_Route_Rewrite</function>example + + array( + "type" => "rewrite", //Yaf_Route_Rewrite route + "match" => "/user-list/:id", //match only /user/list/?/ + "route" => array( + 'controller' => "user", //route to user controller, + 'action' => "list", //route to list action + ), + ), + ); + Yaf_Dispatcher::getInstance()->getRouter()->addConfig( + new Yaf_Config_Simple($config)); +]]> + + &example.outputs.similar; + + "user", + "action" => "list", + "module" => "index", //(default) +) + +/** + * and request parameters: + */ +array( + "id" => 22, +) +]]> + + + + + + &reftitle.seealso; + + Yaf_Router::addRoute + Yaf_Router::addConfig + Yaf_Route_Static + Yaf_Route_Supervar + Yaf_Route_Simple + Yaf_Route_Regex + Yaf_Route_Map + +