<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/yaf.tutorials.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'tr',
  ),
  'this' => 
  array (
    0 => 'yaf.tutorials.routes.php',
    1 => 'Custom Routes',
    2 => 'Custom Routes',
  ),
  'up' => 
  array (
    0 => 'yaf.tutorials.php',
    1 => '&Ouml;rnekler',
  ),
  'prev' => 
  array (
    0 => 'yaf.tutorials.quickstart.php',
    1 => 'Quick Start',
  ),
  'next' => 
  array (
    0 => 'yaf.tutorials.plugins.php',
    1 => 'Plugins',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/yaf/tutorials.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="yaf.tutorials.routes" class="section">
  <h2 class="title">Custom Routes</h2>

 <div class="example" id="example-1">
  <p><strong>Örnek 1 Custom routes</strong></p>
  <div class="example-contents"><p>
   Besides the default <span class="classname"><a href="class.yaf-route-static.php" class="classname">Yaf_Route_Static</a></span> route,
   custom routes can be registered on the
   <span class="classname"><a href="class.yaf-router.php" class="classname">Yaf_Router</a></span> route stack, usually in a
   <code class="literal">_initRoute</code> method of the Bootstrap, using
   <span class="methodname"><a href="yaf-router.addroute.php" class="methodname">Yaf_Router::addRoute()</a></span>. Routes can also be
   declared in configuration files and loaded with
   <span class="methodname"><a href="yaf-router.addconfig.php" class="methodname">Yaf_Router::addConfig()</a></span>.
  </p></div>
  <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: #FF8000">// /user/123 -&gt; controller=user, action=index, id=123
        </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">"user"</span><span style="color: #007700">, new </span><span style="color: #0000BB">Yaf_Route_Rewrite</span><span style="color: #007700">(
            </span><span style="color: #DD0000">"/user/:id"</span><span style="color: #007700">,
            array(</span><span style="color: #DD0000">"controller" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"user"</span><span style="color: #007700">, </span><span style="color: #DD0000">"action" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"index"</span><span style="color: #007700">)
        ));
    }
}
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
  </div>

 </div>

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