php-doc-en/reference/yaf/yaf_route_regex/construct.xml

170 lines
4.7 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="yaf-route-regex.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Yaf_Route_Regex::__construct</refname>
<refpurpose>The __construct purpose</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier><methodname>Yaf_Route_Regex::__construct</methodname>
<methodparam><type>string</type><parameter>match</parameter></methodparam>
<methodparam><type>array</type><parameter>route</parameter></methodparam>
<methodparam choice="opt"><type>array</type><parameter>map</parameter></methodparam>
<methodparam choice="opt"><type>array</type><parameter>verify</parameter></methodparam>
</methodsynopsis>
<para>
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>match</parameter></term>
<listitem>
<para>
A complete Regex pattern, will be used to match a request uri, if
doesn't matched, <classname>Yaf_Route_Regex</classname> will return
FALSE.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>route</parameter></term>
<listitem>
<para>
When the match pattern matches the request uri,
<classname>Yaf_Route_Regex</classname> will use this to decide which
m/c/a to routed.
</para>
<para>
either of m/c/a in this array is optianl, if you don't assgian a
specific value, it will be routed to default.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>map</parameter></term>
<listitem>
<para>
A array to assign name to the captrues in the match result.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>verify</parameter></term>
<listitem>
<para>
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>Yaf_Route_Regex</function>example</title>
<programlisting role="php">
<![CDATA[
<?php
/**
* Add a regex route to Yaf_Router route stack
*/
Yaf_Dispatcher::getInstance()->getRouter()->addRoute("name",
new Yaf_Route_Regex(
"#^/product/([^/]+)/([^/])+#", //match request uri leading "/product"
array(
'controller' => "product", //route to product controller,
),
array(
1 => "name", // now you can call $request->getParam("name")
2 => "id", // to get the first captrue in the match pattern.
)
)
);
?>
]]>
</programlisting>
</example>
<example>
<title><function>Yaf_Route_Regex</function>example</title>
<programlisting role="php">
<![CDATA[
<?php
/**
* Add a regex route to Yaf_Router route stack by calling addconfig
*/
$config = array(
"name" => array(
"type" => "regex", //Yaf_Route_Regex route
"match" => "#(.*)#", //match arbitrary request uri
"route" => array(
'controller' => "product", //route to product controller,
'action' => "dummy", //route to dummy action
),
"map" => array(
1 => "uri", // now you can call $request->getParam("uri")
),
),
);
Yaf_Dispatcher::getInstance()->getRouter()->addConfig(
new Yaf_Config_Simple($config));
?>
]]>
</programlisting>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><methodname>Yaf_Router::addRoute</methodname></member>
<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_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
-->