1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
|
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 332586 $ -->
<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>Yaf_Route_Regex constructor</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>
<methodparam choice="opt"><type>string</type><parameter>reverse</parameter></methodparam>
</methodsynopsis>
<para>
</para>
</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>
<varlistentry>
<term><parameter>reverse</parameter></term>
<listitem>
<para>
a string, used to assemble url, see
<methodname>Yaf_Route_Regex::assemble</methodname>.
<note>
<para>
this parameter is introduced in 2.3.0
</para>
</note>
</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(as of 2.3.0)</function>example</title>
<programlisting role="php">
<![CDATA[
<?php
/**
* Use match result as MVC name
*/
Yaf_Dispatcher::getInstance()->getRouter()->addRoute("name",
new Yaf_Route_Regex(
"#^/product/([^/]+)/([^/])+#i", //match request uri leading "/product"
array(
'controller' => ":name", // route to :name, which is $1 in the match result as controller name
),
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
-->
|