[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-doc-cvs
Subject:    [DOC-CVS] =?utf-8?q?svn:_/phpdoc/en/trunk/reference/yaf/_yaf-route-regex.xml_yaf=5Froute=5Fregex/con
From:       Xinchen_Hui <laruence () php ! net>
Date:       2011-11-28 4:55:20
Message-ID: svn-laruence-1322456120-320070-801616792 () svn ! php ! net
[Download RAW message or body]

laruence                                 Mon, 28 Nov 2011 04:55:20 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=320070

Log:
update docs

Changed paths:
    U   phpdoc/en/trunk/reference/yaf/yaf-route-regex.xml
    U   phpdoc/en/trunk/reference/yaf/yaf_route_regex/construct.xml
    U   phpdoc/en/trunk/reference/yaf/yaf_route_rewrite/construct.xml


["svn-diffs-320070.txt" (text/x-diff)]

Modified: phpdoc/en/trunk/reference/yaf/yaf-route-regex.xml
===================================================================
--- phpdoc/en/trunk/reference/yaf/yaf-route-regex.xml	2011-11-28 04:34:08 UTC (rev 320069)
+++ phpdoc/en/trunk/reference/yaf/yaf-route-regex.xml	2011-11-28 04:55:20 UTC (rev 320070)
@@ -12,7 +12,8 @@
   <section xml:id="yaf-route-regex.intro">
    &reftitle.intro;
    <para>
-
+     <classname>Yaf_Route_Regex</classname> is the most flexible route among
+     the Yaf built-in routes.
    </para>
   </section>
 <!-- }}} -->

Modified: phpdoc/en/trunk/reference/yaf/yaf_route_regex/construct.xml
===================================================================
--- phpdoc/en/trunk/reference/yaf/yaf_route_regex/construct.xml	2011-11-28 04:34:08 UTC (rev 320069)
+++ phpdoc/en/trunk/reference/yaf/yaf_route_regex/construct.xml	2011-11-28 04:55:20 UTC (rev 320070)
@@ -17,7 +17,7 @@
    <methodparam choice="opt"><type>array</type><parameter>verify</parameter></methodparam>
   </methodsynopsis>
   <para>
-
+
   </para>

   &warn.undocumented.func;
@@ -31,7 +31,9 @@
     <term><parameter>match</parameter></term>
     <listitem>
      <para>
-
+       A complete Regex pattern, will be used to match a request uri, if
+       doesn't matched, <classname>Yaf_Route_Regex</classname> will return
+       FALSE.
      </para>
     </listitem>
    </varlistentry>
@@ -39,15 +41,21 @@
     <term><parameter>route</parameter></term>
     <listitem>
      <para>
-
+      When the match pattern matches the request uri,
+      <classname>Yaf_Route_Regex</classname> will use this to decide which
+      m/c/a to routed.
      </para>
+     <para>
+      either of m/c/a in this array is optianl, if you don't assgian a
+      specific value, it will be routed to default.
+     </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>map</parameter></term>
     <listitem>
      <para>
-
+      A array to assign name to the captrues in the match result.
      </para>
     </listitem>
    </varlistentry>
@@ -69,7 +77,72 @@
   </para>
  </refsect1>

+ <refsect1 role="examples">
+  &reftitle.examples;
+  <example>
+   <title><function>Yaf_Route_Regex</function>example</title>
+   <programlisting role="php">
+<![CDATA[
+<?php
+   /**
+    * Add a regex route to Yaf_Router route stack
+    */
+    Yaf_Dispatcher::getInstance()->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.
+           )
+        )
+    );
+]]>
+   </programlisting>
+  </example>
+  <example>
+   <title><function>Yaf_Route_Regex</function>example</title>
+   <programlisting role="php">
+<![CDATA[
+<?php
+   /**
+    * Add a regex route to Yaf_Router route stack by calling addconfig
+    */
+    $config = array(
+        "name" => 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));
+]]>
+   </programlisting>
+  </example>
+ </refsect1>

+ <refsect1 role="seealso">
+  &reftitle.seealso;
+  <simplelist>
+   <member><methodname>Yaf_Router::addRoute</methodname></member>
+   <member><methodname>Yaf_Router::addConfig</methodname></member>
+   <member><classname>Yaf_Route_Static</classname></member>
+   <member><classname>Yaf_Route_Supervar</classname></member>
+   <member><classname>Yaf_Route_Simple</classname></member>
+   <member><classname>Yaf_Route_Rewrite</classname></member>
+   <member><classname>Yaf_Route_Map</classname></member>
+  </simplelist>
+ </refsect1>
+
 </refentry>

 <!-- Keep this comment at the end of the file

Modified: phpdoc/en/trunk/reference/yaf/yaf_route_rewrite/construct.xml
===================================================================
--- phpdoc/en/trunk/reference/yaf/yaf_route_rewrite/construct.xml	2011-11-28 04:34:08 UTC (rev 320069)
+++ phpdoc/en/trunk/reference/yaf/yaf_route_rewrite/construct.xml	2011-11-28 04:55:20 UTC (rev 320070)
@@ -30,7 +30,9 @@
     <term><parameter>match</parameter></term>
     <listitem>
      <para>
-
+       A pattern, will be used to match a request uri, if
+       doesn't matched, <classname>Yaf_Route_Rewrite</classname> will return
+       FALSE.
      </para>
     </listitem>
    </varlistentry>
@@ -38,8 +40,14 @@
     <term><parameter>route</parameter></term>
     <listitem>
      <para>
-
+      When the match pattern matches the request uri,
+      <classname>Yaf_Route_Rewrite</classname> will use this to decide which
+      m/c/a to routed.
      </para>
+     <para>
+      either of m/c/a in this array is optianl, if you don't assgian a
+      specific value, it will be routed to default.
+     </para>
     </listitem>
    </varlistentry>
    <varlistentry>
@@ -60,7 +68,107 @@
   </para>
  </refsect1>

+ <refsect1 role="examples">
+  &reftitle.examples;
+  <example>
+   <title><function>Yaf_Route_Rewrite</function>example</title>
+   <programlisting role="php">
+<![CDATA[
+<?php
+   /**
+    * Add a rewrite route to Yaf_Router route stack
+    */
+    Yaf_Dispatcher::getInstance()->getRouter()->addRoute("name",
+        new Yaf_Route_rewrite(
+           "/product/:name/:id/*", //match request uri leading "/product"
+           array(
+               'controller' => "product",  //route to product controller,
+           ),
+        )
+    );
+]]>
+   </programlisting>
+   &example.outputs.similar;
+   <screen>
+<![CDATA[
+/* for http://yourdomain.com/product/foo/22/foo/bar
+ * route will result in following values:
+ */
+array(
+  "controller" => "product",
+  "module"     => "index", //(default)
+  "action"     => "index", //(default)
+)

+/**
+ * and request parameters:
+ */
+array(
+  "name" => "foo",
+  "id"   => 22,
+  "foo"  => bar
+)
+]]>
+   </screen>
+  </example>
+  <example>
+   <title><function>Yaf_Route_Rewrite</function>example</title>
+   <programlisting role="php">
+<![CDATA[
+    <?php
+   /**
+    * Add a rewrite route to Yaf_Router route stack by calling addconfig
+    */
+    $config = array(
+        "name" => 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));
+]]>
+   </programlisting>
+   &example.outputs.similar;
+   <screen>
+<![CDATA[
+/* for http://yourdomain.com/user-list/22
+ * route will result in following values:
+ */
+array(
+  "controller" => "user",
+  "action"     => "list",
+  "module"     => "index", //(default)
+)
+
+/**
+ * and request parameters:
+ */
+array(
+  "id"   => 22,
+)
+]]>
+   </screen>
+  </example>
+ </refsect1>
+
+ <refsect1 role="seealso">
+  &reftitle.seealso;
+  <simplelist>
+   <member><methodname>Yaf_Router::addRoute</methodname></member>
+   <member><methodname>Yaf_Router::addConfig</methodname></member>
+   <member><classname>Yaf_Route_Static</classname></member>
+   <member><classname>Yaf_Route_Supervar</classname></member>
+   <member><classname>Yaf_Route_Simple</classname></member>
+   <member><classname>Yaf_Route_Regex</classname></member>
+   <member><classname>Yaf_Route_Map</classname></member>
+  </simplelist>
+ </refsect1>
+
 </refentry>

 <!-- Keep this comment at the end of the file


-- 
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic