<?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-rewrite.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'yaf-route-rewrite.route.php',
    1 => 'Yaf_Route_Rewrite::route',
    2 => 'Route a request',
  ),
  'up' => 
  array (
    0 => 'class.yaf-route-rewrite.php',
    1 => 'Yaf_Route_Rewrite',
  ),
  'prev' => 
  array (
    0 => 'yaf-route-rewrite.construct.php',
    1 => 'Yaf_Route_Rewrite::__construct',
  ),
  'next' => 
  array (
    0 => 'class.yaf-router.php',
    1 => 'Yaf_Router',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/yaf/yaf_route_rewrite/route.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="yaf-route-rewrite.route" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Yaf_Route_Rewrite::route</h1>
  <p class="verinfo">(Yaf &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">Yaf_Route_Rewrite::route</span> &mdash; <span class="dc-title">Route a request</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yaf-route-rewrite.route-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">function</span> <span class="methodname"><strong>Yaf_Route_Rewrite::route</strong></span>(<span class="methodparam"><span class="type"><a href="class.yaf-request-abstract.php" class="type Yaf_Request_Abstract">Yaf_Request_Abstract</a></span> <code class="parameter">$request</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="simpara">Route the request by matching the URI against the match pattern given to the constructor. When it matches, the module, controller and action are taken from the route array, where a value starting with a colon is resolved from the matched variables.</p>
 </div>


 <div class="refsect1 parameters" id="refsect1-yaf-route-rewrite.route-parameters">
  <h3 class="title">Parameters</h3>
  <dl>
   
    <dt><code class="parameter">request</code></dt>
    <dd>
     <p class="simpara">The <span class="classname"><a href="class.yaf-request-abstract.php" class="classname">Yaf_Request_Abstract</a></span> instance to route.</p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-yaf-route-rewrite.route-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="simpara">Returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> if the URI matches, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> otherwise, which makes the router try the next route.</p>
 </div>


 <div class="refsect1 examples" id="refsect1-yaf-route-rewrite.route-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-1">
   <p><strong>Example #1 <span class="methodname"><strong>Yaf_Route_Rewrite::route()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php
</span><span style="color: #FF8000">/* assume the request URI is "/product/php-book" */
</span><span style="color: #0000BB">$request </span><span style="color: #007700">= new </span><span style="color: #0000BB">Yaf_Request_Http</span><span style="color: #007700">(</span><span style="color: #DD0000">"/product/php-book"</span><span style="color: #007700">);

</span><span style="color: #0000BB">$route </span><span style="color: #007700">= new </span><span style="color: #0000BB">Yaf_Route_Rewrite</span><span style="color: #007700">(
    </span><span style="color: #DD0000">"/product/:name"</span><span style="color: #007700">,             </span><span style="color: #FF8000">// match a URI leading "/product"
    </span><span style="color: #007700">array(
        </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 the product controller
    </span><span style="color: #007700">),
    array()                        </span><span style="color: #FF8000">// no default values
</span><span style="color: #007700">);

</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$route</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">route</span><span style="color: #007700">(</span><span style="color: #0000BB">$request</span><span style="color: #007700">));

</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$request</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getControllerName</span><span style="color: #007700">());
</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$request</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getParam</span><span style="color: #007700">(</span><span style="color: #DD0000">"name"</span><span style="color: #007700">));
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
   </div>

   <div class="example-contents"><p>The above example will output
something similar to:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">bool(true)
string(7) &quot;product&quot;
string(8) &quot;php-book&quot;</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-yaf-route-rewrite.route-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="yaf-route-rewrite.construct.php" class="methodname" rel="rdfs-seeAlso">Yaf_Route_Rewrite::__construct()</a> - Yaf_Route_Rewrite constructor</span></li>
   <li><span class="methodname"><strong>Yaf_Route_Rewrite::match()</strong></span></li>
   <li><span class="methodname"><a href="yaf-route-rewrite.assemble.php" class="methodname" rel="rdfs-seeAlso">Yaf_Route_Rewrite::assemble()</a> - Assemble a url</span></li>
  </ul>
 </div>

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