<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.yaf-router.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'tr',
  ),
  'this' => 
  array (
    0 => 'yaf-router.route.php',
    1 => 'Yaf_Router::route',
    2 => 'Route a request',
  ),
  'up' => 
  array (
    0 => 'class.yaf-router.php',
    1 => 'Yaf_Router',
  ),
  'prev' => 
  array (
    0 => 'yaf-router.getroutes.php',
    1 => 'Yaf_Router::getRoutes',
  ),
  'next' => 
  array (
    0 => 'class.yaf-route-simple.php',
    1 => 'Yaf_Route_Simple',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/yaf/yaf_router/route.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

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

 </div>

 <div class="refsect1 description" id="refsect1-yaf-router.route-description">
  <h3 class="title">Açıklama</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">function</span> <span class="methodname"><strong>Yaf_Router::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"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></span></div>

  <p class="simpara">Route the request with the registered routes.</p>
  <p class="simpara">Routes are tried in reverse order of registration. The first route that claims the request wins; the request is then marked as routed (see <span class="methodname"><a href="yaf-request-abstract.setrouted.php" class="methodname">Yaf_Request_Abstract::setRouted()</a></span>) and the name of the winning route is recorded, which can be retrieved via <span class="methodname"><a href="yaf-router.getcurrentroute.php" class="methodname">Yaf_Router::getCurrentRoute()</a></span>.</p>
  <p class="simpara">The default route, registered as <code class="literal">_default</code>, is <span class="classname"><a href="class.yaf-route-static.php" class="classname">Yaf_Route_Static</a></span> unless a custom default route is configured.</p>
 </div>


 <div class="refsect1 parameters" id="refsect1-yaf-router.route-parameters">
  <h3 class="title">Bağımsız Değişkenler</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-router.route-returnvalues">
  <h3 class="title">Dönen Değerler</h3>
<p class="simpara">Returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> if the request has been routed, or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> if no route matched (e.g. a malformed URI), which makes the dispatcher stop.</p>
 </div>


 <div class="refsect1 examples" id="refsect1-yaf-router.route-examples">
  <h3 class="title">Örnekler</h3>
  <div class="example" id="example-1">
   <p><strong>Örnek 1 <span class="methodname"><strong>Yaf_Router::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: #007700">class </span><span style="color: #0000BB">Bootstrap </span><span style="color: #007700">extends </span><span style="color: #0000BB">Yaf_Bootstrap_Abstract
</span><span style="color: #007700">{
    public function </span><span style="color: #0000BB">_initRoute</span><span style="color: #007700">(</span><span style="color: #0000BB">Yaf_Dispatcher $dispatcher</span><span style="color: #007700">)
    {
        </span><span style="color: #0000BB">$router </span><span style="color: #007700">= </span><span style="color: #0000BB">$dispatcher</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getRouter</span><span style="color: #007700">();

        </span><span style="color: #0000BB">$router</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addRoute</span><span style="color: #007700">(</span><span style="color: #DD0000">"rewrite"</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/:id"</span><span style="color: #007700">,
            [</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: #DD0000">"action" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"detail"</span><span style="color: #007700">]
        ));

        </span><span style="color: #FF8000">/* route a hand-built request, e.g. in a unit test */
        </span><span style="color: #0000BB">$request </span><span style="color: #007700">= new </span><span style="color: #0000BB">Yaf_Request_Simple</span><span style="color: #007700">(</span><span style="color: #DD0000">"CLI"</span><span style="color: #007700">, </span><span style="color: #0000BB">null</span><span style="color: #007700">, </span><span style="color: #DD0000">"index.php"</span><span style="color: #007700">,
            </span><span style="color: #DD0000">"/product/123"</span><span style="color: #007700">, </span><span style="color: #0000BB">null</span><span style="color: #007700">);

        if (</span><span style="color: #0000BB">$router</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">$router</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getCurrentRoute</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">getActionName</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">"id"</span><span style="color: #007700">));
        } else {
            </span><span style="color: #FF8000">/* no route matched */
        </span><span style="color: #007700">}
    }
}
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
   </div>

   <div class="example-contents"><p>
Yukarıdaki örnek şuna benzer bir çıktı üretir:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">string(7) &quot;rewrite&quot;
string(7) &quot;product&quot;
string(6) &quot;detail&quot;
string(3) &quot;123&quot;</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-yaf-router.route-seealso">
  <h3 class="title">Ayrıca Bakınız</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.getcurrentroute.php" class="methodname" rel="rdfs-seeAlso">Yaf_Router::getCurrentRoute()</a> - Get the effective route name</span></li>
   <li><span class="methodname"><a href="yaf-dispatcher.dispatch.php" class="methodname" rel="rdfs-seeAlso">Yaf_Dispatcher::dispatch()</a> - Dispatch a request</span></li>
  </ul>
 </div>

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