<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.yaf-route-regex.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'yaf-route-regex.construct.php',
    1 => 'Yaf_Route_Regex::__construct',
    2 => 'Yaf_Route_Regex constructor',
  ),
  'up' => 
  array (
    0 => 'class.yaf-route-regex.php',
    1 => 'Yaf_Route_Regex',
  ),
  'prev' => 
  array (
    0 => 'yaf-route-regex.assemble.php',
    1 => 'Yaf_Route_Regex::assemble',
  ),
  'next' => 
  array (
    0 => 'yaf-route-regex.route.php',
    1 => 'Yaf_Route_Regex::route',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/yaf/yaf_route_regex/construct.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="yaf-route-regex.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Yaf_Route_Regex::__construct</h1>
  <p class="verinfo">(Yaf &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">Yaf_Route_Regex::__construct</span> &mdash; <span class="dc-title">Yaf_Route_Regex constructor</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yaf-route-regex.construct-description">
  <h3 class="title">Descrizione</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Yaf_Route_Regex::__construct</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$match</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$route</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$map</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$verify</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$reverse</code><span class="initializer"> = ?</span></span><br>)</div>

  <p class="para rdfs-comment">
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-yaf-route-regex.construct-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <dl>
   
    <dt><code class="parameter">match</code></dt>
    <dd>
     <p class="para">
       A complete Regex pattern, will be used to match a request uri, if
       doesn&#039;t matched, <span class="classname"><a href="class.yaf-route-regex.php" class="classname">Yaf_Route_Regex</a></span> will return
       <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
     </p>
    </dd>
   
   
    <dt><code class="parameter">route</code></dt>
    <dd>
     <p class="para">
      When the match pattern matches the request uri,
      <span class="classname"><a href="class.yaf-route-regex.php" class="classname">Yaf_Route_Regex</a></span> will use this to decide which
      m/c/a to routed.
     </p>
     <p class="para">
      either of m/c/a in this array is optional, if you don&#039;t assign a
      specific value, it will be routed to default.
     </p>
    </dd>
   
   
    <dt><code class="parameter">map</code></dt>
    <dd>
     <p class="para">
      An array to assign name to the captures in the match result.
     </p>
    </dd>
   
   
    <dt><code class="parameter">verify</code></dt>
    <dd>
     <p class="para">
      
     </p>
    </dd>
   
   
    <dt><code class="parameter">reverse</code></dt>
    <dd>
     <p class="para">
      a string, used to assemble url, see
      <span class="methodname"><a href="yaf-route-regex.assemble.php" class="methodname">Yaf_Route_Regex::assemble()</a></span>.
      <blockquote class="note"><p><strong class="note">Nota</strong>: 
       <p class="para">
       this parameter is introduced in 2.3.0
       </p>
      </p></blockquote>
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-yaf-route-regex.construct-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-yaf-route-regex.construct-examples">
  <h3 class="title">Esempi</h3>
  <div class="example" id="example-1">
   <p><strong>Example #1 <span class="classname"><a href="class.yaf-route-regex.php" class="classname">Yaf_Route_Regex</a></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />   </span><span style="color: #FF8000">/**<br />    * Add a regex route to Yaf_Router route stack<br />    */<br />    </span><span style="color: #0000BB">Yaf_Dispatcher</span><span style="color: #007700">::</span><span style="color: #0000BB">getInstance</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">getRouter</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">addRoute</span><span style="color: #007700">(</span><span style="color: #DD0000">"name"</span><span style="color: #007700">,<br />        new </span><span style="color: #0000BB">Yaf_Route_Regex</span><span style="color: #007700">(<br />           </span><span style="color: #DD0000">"#^/product/([^/]+)/([^/])+#"</span><span style="color: #007700">, </span><span style="color: #FF8000">//match request uri leading "/product"<br />           </span><span style="color: #007700">array(<br />               </span><span style="color: #DD0000">'controller' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"product"</span><span style="color: #007700">,  </span><span style="color: #FF8000">//route to product controller,<br />           </span><span style="color: #007700">),<br />           array(<br />              </span><span style="color: #0000BB">1 </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"name"</span><span style="color: #007700">,   </span><span style="color: #FF8000">// now you can call $request-&gt;getParam("name")<br />              </span><span style="color: #0000BB">2 </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"id"</span><span style="color: #007700">,     </span><span style="color: #FF8000">// to get the first captrue in the match pattern.<br />           </span><span style="color: #007700">)<br />        )<br />    );<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
  <div class="example" id="example-2">
   <p><strong>Example #2 <span class="classname"><a href="class.yaf-route-regex.php" class="classname">Yaf_Route_Regex</a></span> (as of 2.3.0) example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />   </span><span style="color: #FF8000">/**<br />    * Use match result as MVC name<br />    */<br />    </span><span style="color: #0000BB">Yaf_Dispatcher</span><span style="color: #007700">::</span><span style="color: #0000BB">getInstance</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">getRouter</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">addRoute</span><span style="color: #007700">(</span><span style="color: #DD0000">"name"</span><span style="color: #007700">,<br />        new </span><span style="color: #0000BB">Yaf_Route_Regex</span><span style="color: #007700">(<br />           </span><span style="color: #DD0000">"#^/product/([^/]+)/([^/])+#i"</span><span style="color: #007700">, </span><span style="color: #FF8000">//match request uri leading "/product"<br />           </span><span style="color: #007700">array(<br />              </span><span style="color: #DD0000">'controller' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">":name"</span><span style="color: #007700">, </span><span style="color: #FF8000">// route to :name, which is $1 in the match result as controller name<br />           </span><span style="color: #007700">),<br />           array(<br />              </span><span style="color: #0000BB">1 </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"name"</span><span style="color: #007700">,   </span><span style="color: #FF8000">// now you can call $request-&gt;getParam("name")<br />              </span><span style="color: #0000BB">2 </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"id"</span><span style="color: #007700">,     </span><span style="color: #FF8000">// to get the first captrue in the match pattern.<br />           </span><span style="color: #007700">)<br />        )<br />    );<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
  <div class="example" id="example-3">
   <p><strong>Example #3 <span class="classname"><a href="class.yaf-route-regex.php" class="classname">Yaf_Route_Regex</a></span> and named capture group (as of 2.3.0) example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />   </span><span style="color: #FF8000">/**<br />    * Use match result as MVC name<br />    */<br />    </span><span style="color: #0000BB">Yaf_Dispatcher</span><span style="color: #007700">::</span><span style="color: #0000BB">getInstance</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">getRouter</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">addRoute</span><span style="color: #007700">(</span><span style="color: #DD0000">"name"</span><span style="color: #007700">,<br />        new </span><span style="color: #0000BB">Yaf_Route_Regex</span><span style="color: #007700">(<br />           </span><span style="color: #DD0000">"#^/product/(?&lt;name&gt;[^/]+)/([^/])+#i"</span><span style="color: #007700">, </span><span style="color: #FF8000">//match request uri leading "/product"<br />           </span><span style="color: #007700">array(<br />           </span><span style="color: #DD0000">'controller' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">":name"</span><span style="color: #007700">, </span><span style="color: #FF8000">// route to :name,<br />                                    // which is named capture group 'name' in the match result as controller name<br />           </span><span style="color: #007700">),<br />           array(<br />              </span><span style="color: #0000BB">2 </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"id"</span><span style="color: #007700">,     </span><span style="color: #FF8000">// to get the first captrue in the match pattern.<br />           </span><span style="color: #007700">)<br />        )<br />    );<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
  <div class="example" id="example-4">
   <p><strong>Example #4 <span class="classname"><a href="class.yaf-route-regex.php" class="classname">Yaf_Route_Regex</a></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />   </span><span style="color: #FF8000">/**<br />    * Add a regex route to Yaf_Router route stack by calling addconfig<br />    */<br />    </span><span style="color: #0000BB">$config </span><span style="color: #007700">= array(<br />        </span><span style="color: #DD0000">"name" </span><span style="color: #007700">=&gt; array(<br />           </span><span style="color: #DD0000">"type"  </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"regex"</span><span style="color: #007700">,          </span><span style="color: #FF8000">//Yaf_Route_Regex route<br />           </span><span style="color: #DD0000">"match" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"#(.*)#"</span><span style="color: #007700">,         </span><span style="color: #FF8000">//match arbitrary request uri<br />           </span><span style="color: #DD0000">"route" </span><span style="color: #007700">=&gt; array(<br />               </span><span style="color: #DD0000">'controller' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"product"</span><span style="color: #007700">,  </span><span style="color: #FF8000">//route to product controller,<br />               </span><span style="color: #DD0000">'action'     </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"dummy"</span><span style="color: #007700">,    </span><span style="color: #FF8000">//route to dummy action<br />           </span><span style="color: #007700">),<br />           </span><span style="color: #DD0000">"map" </span><span style="color: #007700">=&gt; array(<br />              </span><span style="color: #0000BB">1 </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"uri"</span><span style="color: #007700">,   </span><span style="color: #FF8000">// now you can call $request-&gt;getParam("uri")<br />           </span><span style="color: #007700">),<br />        ),<br />    );<br />    </span><span style="color: #0000BB">Yaf_Dispatcher</span><span style="color: #007700">::</span><span style="color: #0000BB">getInstance</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">getRouter</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">addConfig</span><span style="color: #007700">(<br />        new </span><span style="color: #0000BB">Yaf_Config_Simple</span><span style="color: #007700">(</span><span style="color: #0000BB">$config</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-yaf-route-regex.construct-seealso">
  <h3 class="title">Vedere anche:</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="yaf-router.addroute.php" class="methodname" rel="rdfs-seeAlso">Yaf_Router::addRoute()</a> - Add new Route into Router</span></li>
   <li><span class="methodname"><a href="yaf-router.addconfig.php" class="methodname" rel="rdfs-seeAlso">Yaf_Router::addConfig()</a> - Add config-defined routes into Router</span></li>
   <li><span class="classname"><a href="class.yaf-route-static.php" class="classname">Yaf_Route_Static</a></span></li>
   <li><span class="classname"><a href="class.yaf-route-supervar.php" class="classname">Yaf_Route_Supervar</a></span></li>
   <li><span class="classname"><a href="class.yaf-route-simple.php" class="classname">Yaf_Route_Simple</a></span></li>
   <li><span class="classname"><a href="class.yaf-route-rewrite.php" class="classname">Yaf_Route_Rewrite</a></span></li>
   <li><span class="classname"><a href="class.yaf-route-map.php" class="classname">Yaf_Route_Map</a></span></li>
  </ul>                       
 </div>
  

</div><?php manual_footer($setup); ?>