<?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 => 'it',
  ),
  'this' => 
  array (
    0 => 'yaf-router.addroute.php',
    1 => 'Yaf_Router::addRoute',
    2 => 'Add new Route into Router',
  ),
  'up' => 
  array (
    0 => 'class.yaf-router.php',
    1 => 'Yaf_Router',
  ),
  'prev' => 
  array (
    0 => 'yaf-router.addconfig.php',
    1 => 'Yaf_Router::addConfig',
  ),
  'next' => 
  array (
    0 => 'yaf-router.construct.php',
    1 => 'Yaf_Router::__construct',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/yaf/yaf_router/addroute.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="yaf-router.addroute" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Yaf_Router::addRoute</h1>
  <p class="verinfo">(Yaf &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">Yaf_Router::addRoute</span> &mdash; <span class="dc-title">Add new Route into Router</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yaf-router.addroute-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Yaf_Router::addRoute</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$name</code></span>, <span class="methodparam"><span class="type">Yaf_Route_Abstract</span> <code class="parameter">$route</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
    defaultly, Yaf_Router using a <span class="classname"><a href="class.yaf-route-static.php" class="classname">Yaf_Route_Static</a></span> as its defualt route. you
    can add new routes into router&#039;s route stack by calling this method.
  </p>
  <p class="para">
    the newer route will be called before the older(route stack), and if the newer router return
    <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, the router process will be end. otherwise, the older one will be
    called.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-yaf-router.addroute-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">Questa funzione non contiene parametri.</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-yaf-router.addroute-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-yaf-router.addroute-examples">
  <h3 class="title">Esempi</h3>
  <div class="example" id="example-1">
   <p><strong>Example #1 <span class="function"><a href="yaf-dispatcher.autorender.php" class="function">Yaf_Dispatcher::autoRender()</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: #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">{<br />    public function </span><span style="color: #0000BB">_initConfig</span><span style="color: #007700">() {<br />        </span><span style="color: #0000BB">$config </span><span style="color: #007700">= </span><span style="color: #0000BB">Yaf_Application</span><span style="color: #007700">::</span><span style="color: #0000BB">app</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">getConfig</span><span style="color: #007700">();<br />        </span><span style="color: #0000BB">Yaf_Registry</span><span style="color: #007700">::</span><span style="color: #0000BB">set</span><span style="color: #007700">(</span><span style="color: #DD0000">"config"</span><span style="color: #007700">, </span><span style="color: #0000BB">$config</span><span style="color: #007700">);<br />    }<br /><br />    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">) {<br />        </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">();<br />        </span><span style="color: #FF8000">/**<br />         * we can add some pre-defined routes in application.ini<br />         */<br />        </span><span style="color: #0000BB">$router</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addConfig</span><span style="color: #007700">(</span><span style="color: #0000BB">Yaf_Registry</span><span style="color: #007700">::</span><span style="color: #0000BB">get</span><span style="color: #007700">(</span><span style="color: #DD0000">"config"</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">routes</span><span style="color: #007700">);<br />        </span><span style="color: #FF8000">/**<br />         * add a Rewrite route, then for a request uri: <br />         * http://example.com/product/list/22/foo<br />         * will be matched by this route, and result:<br />         *<br />         *  [module] =&gt; <br />         *  [controller] =&gt; product<br />         *  [action] =&gt; info<br />         *  [method] =&gt; GET<br />         *  [params:protected] =&gt; Array<br />         *      (<br />         *          [id] =&gt; 22<br />         *          [name] =&gt; foo<br />         *      )<br />         * <br />         */<br />        </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">(<br />            </span><span style="color: #DD0000">"/product/list/:id/:name"</span><span style="color: #007700">,<br />            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">,<br />                </span><span style="color: #DD0000">"action"     </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"info"</span><span style="color: #007700">,<br />            )<br />        ); <br />        <br />        </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">'dummy'</span><span style="color: #007700">, </span><span style="color: #0000BB">$route</span><span style="color: #007700">);<br />    }<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-yaf-router.addroute-seealso">
  <h3 class="title">Vedere anche:</h3>
  <ul class="simplelist">
   <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-regex.php" class="classname">Yaf_Route_Regex</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); ?>