mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-21 03:18:55 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@328221 c90b9560-bf6c-de11-be94-00142212c4b1
125 lines
3.6 KiB
XML
125 lines
3.6 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
|
|
<refentry xml:id="yaf-router.addroute" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>Yaf_Router::addRoute</refname>
|
|
<refpurpose>Add new Route into Router</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<modifier>public</modifier> <type>bool</type><methodname>Yaf_Router::addRoute</methodname>
|
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
|
<methodparam><type>Yaf_Route_Abstract</type><parameter>route</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
defaultly, Yaf_Router using a <classname>Yaf_Route_Static</classname> as its defualt route. you
|
|
can add new routes into router's route stack by calling this method.
|
|
</para>
|
|
<para>
|
|
the newer route will be called before the older(route stack), and if the newer router return
|
|
&true;, the router process will be end. otherwise, the older one will be
|
|
called.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
&no.function.parameters;
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<example>
|
|
<title><function>Yaf_Dispatcher::autoRender</function>example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
class Bootstrap extends Yaf_Bootstrap_Abstract{
|
|
public function _initConfig() {
|
|
$config = Yaf_Application::app()->getConfig();
|
|
Yaf_Registry::set("config", $config);
|
|
}
|
|
|
|
public function _initRoute(Yaf_Dispatcher $dispatcher) {
|
|
$router = $dispatcher->getRouter();
|
|
/**
|
|
* we can add some pre-defined routes in application.ini
|
|
*/
|
|
$router->addConfig(Yaf_Registry::get("config")->routes);
|
|
/**
|
|
* add a Rewrite route, then for a request uri:
|
|
* http://***/product/list/22/foo
|
|
* will be matched by this route, and result:
|
|
*
|
|
* [module] =>
|
|
* [controller] => product
|
|
* [action] => info
|
|
* [method] => GET
|
|
* [params:protected] => Array
|
|
* (
|
|
* [id] => 22
|
|
* [name] => foo
|
|
* )
|
|
*
|
|
*/
|
|
$route = new Yaf_Route_Rewrite(
|
|
"/product/list/:id/:name",
|
|
array(
|
|
"controller" => "product",
|
|
"action" => "info",
|
|
)
|
|
);
|
|
|
|
$router->addRoute('dummy', $route);
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<simplelist>
|
|
<member><methodname>Yaf_Router::addConfig</methodname></member>
|
|
<member><classname>Yaf_Route_Static</classname></member>
|
|
<member><classname>Yaf_Route_Supervar</classname></member>
|
|
<member><classname>Yaf_Route_Simple</classname></member>
|
|
<member><classname>Yaf_Route_Regex</classname></member>
|
|
<member><classname>Yaf_Route_Rewrite</classname></member>
|
|
<member><classname>Yaf_Route_Map</classname></member>
|
|
</simplelist>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|