<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.yaf-route-regex.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'yaf-route-regex.construct.php',
    1 => 'Yaf_Route_Regex::__construct',
    2 => 'Yaf_Route_Regex constructor',
  ),
  'up' => 
  array (
    0 => 'class.yaf-route-regex.php',
    1 => 'Yaf_Route_Regex',
  ),
  'prev' => 
  array (
    0 => 'yaf-route-regex.assemble.php',
    1 => 'Yaf_Route_Regex::assemble',
  ),
  'next' => 
  array (
    0 => 'yaf-route-regex.route.php',
    1 => 'Yaf_Route_Regex::route',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/yaf/yaf_route_regex/construct.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="yaf-route-regex.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Yaf_Route_Regex::__construct</h1>
  <p class="verinfo">(Yaf &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">Yaf_Route_Regex::__construct</span> &mdash; <span class="dc-title">Yaf_Route_Regex constructor</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yaf-route-regex.construct-description">
  <h3 class="title">Опис</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">function</span> <span class="methodname"><strong>Yaf_Route_Regex::__construct</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$match</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$route</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.array.php" class="type array">array</a></span></span> <code class="parameter">$map</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.array.php" class="type array">array</a></span></span> <code class="parameter">$verify</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$reverse</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span><br>)</div>

  <p class="simpara">
   Constructs a <span class="classname"><a href="class.yaf-route-regex.php" class="classname">Yaf_Route_Regex</a></span> route, which routes a
   request URI matching a regular expression to a module, controller and action.
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-yaf-route-regex.construct-parameters">
  <h3 class="title">Параметри</h3>
  <dl>
   
    <dt><code class="parameter">match</code></dt>
    <dd>
     <p class="simpara">
      A complete regular expression pattern, used to match the request URI.
      When it does not match, <span class="methodname"><a href="yaf-route-regex.route.php" class="methodname">Yaf_Route_Regex::route()</a></span>
      returns <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> and the router moves on to the next route.
     </p>
    </dd>
   
   
    <dt><code class="parameter">route</code></dt>
    <dd>
     <p class="simpara">
      When the pattern matches the request URI, this <span class="type"><a href="language.types.array.php" class="type array">array</a></span> determines the
      module, controller and action to route to.
     </p>
     <p class="simpara">
      Each of the three entries is optional; when one is not given, the
      default is used. An entry whose value starts with <code class="literal">:</code>
      is resolved against the parameters produced by
      <code class="parameter">map</code>.
     </p>
    </dd>
   
   
    <dt><code class="parameter">map</code></dt>
    <dd>
     <p class="simpara">
      An <span class="type"><a href="language.types.array.php" class="type array">array</a></span> mapping capture group indexes to parameter names. Only the
      captures listed here become request parameters; a numeric capture that
      is not listed is discarded.
     </p>
     <p class="simpara">
      Named capture groups are always added under their own name and do not
      need to be listed.
     </p>
    </dd>
   
   
    <dt><code class="parameter">verify</code></dt>
    <dd>
     <p class="simpara">
      Accepted and stored on the route, but not used: the current
      implementation never consults it while routing.
     </p>
    </dd>
   
   
    <dt><code class="parameter">reverse</code></dt>
    <dd>
     <p class="para">
      A <span class="type"><a href="language.types.string.php" class="type string">string</a></span>, used to assemble URL, see
      <span class="methodname"><a href="yaf-route-regex.assemble.php" class="methodname">Yaf_Route_Regex::assemble()</a></span>.
      <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
       <p class="simpara">
        This parameter is introduced in 2.3.0
       </p>
      </p></blockquote>
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-yaf-route-regex.construct-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="simpara">No value is returned.</p>
 </div>


 <div class="refsect1 examples" id="refsect1-yaf-route-regex.construct-examples">
  <h3 class="title">Приклади</h3>
  <div class="example" id="example-1">
   <p><strong>Приклад #1 <span class="classname"><a href="class.yaf-route-regex.php" class="classname">Yaf_Route_Regex</a></span> via <span class="methodname"><a href="yaf-router.addroute.php" class="methodname">Yaf_Router::addRoute()</a></span></strong></p>
   <div class="example-contents">
<div class="phpcode"><pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php

</span><span style="color: #FF8000">/**
 * Add a regex route to the Yaf_Router route stack
 */
</span><span style="color: #0000BB">Yaf_Dispatcher</span><span style="color: #007700">::</span><span style="color: #0000BB">getInstance</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">getRouter</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">addRoute</span><span style="color: #007700">(
    </span><span style="color: #DD0000">"name"</span><span style="color: #007700">,
    new </span><span style="color: #0000BB">Yaf_Route_Regex</span><span style="color: #007700">(
        </span><span style="color: #DD0000">"#^/product/([^/]+)/([^/]+)#"</span><span style="color: #007700">, </span><span style="color: #FF8000">// match a URI leading "/product"
        </span><span style="color: #007700">array(
            </span><span style="color: #DD0000">'controller' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"product"</span><span style="color: #007700">, </span><span style="color: #FF8000">// route to the product controller
        </span><span style="color: #007700">),
        array(
            </span><span style="color: #0000BB">1 </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"name"</span><span style="color: #007700">, </span><span style="color: #FF8000">// $request-&gt;getParam("name") holds the first capture
            </span><span style="color: #0000BB">2 </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"id"</span><span style="color: #007700">,   </span><span style="color: #FF8000">// and $request-&gt;getParam("id") the second
        </span><span style="color: #007700">)
    )
);
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
   </div>

  </div>
  <div class="example" id="example-2">
   <p><strong>Приклад #2 <span class="classname"><a href="class.yaf-route-regex.php" class="classname">Yaf_Route_Regex</a></span> using a capture as the controller name</strong></p>
   <div class="example-contents">
<div class="phpcode"><pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php

</span><span style="color: #FF8000">/**
 * Use a capture as the controller name
 */
</span><span style="color: #0000BB">Yaf_Dispatcher</span><span style="color: #007700">::</span><span style="color: #0000BB">getInstance</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">getRouter</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">addRoute</span><span style="color: #007700">(
    </span><span style="color: #DD0000">"name"</span><span style="color: #007700">,
    new </span><span style="color: #0000BB">Yaf_Route_Regex</span><span style="color: #007700">(
        </span><span style="color: #DD0000">"#^/product/([^/]+)/([^/]+)#i"</span><span style="color: #007700">, </span><span style="color: #FF8000">// match a URI leading "/product"
        </span><span style="color: #007700">array(
            </span><span style="color: #DD0000">'controller' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">":name"</span><span style="color: #007700">, </span><span style="color: #FF8000">// the "name" capture (see map) becomes the controller
        </span><span style="color: #007700">),
        array(
            </span><span style="color: #0000BB">1 </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"name"</span><span style="color: #007700">, </span><span style="color: #FF8000">// $request-&gt;getParam("name") holds the first capture
            </span><span style="color: #0000BB">2 </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"id"</span><span style="color: #007700">,   </span><span style="color: #FF8000">// and $request-&gt;getParam("id") the second
        </span><span style="color: #007700">)
    )
);
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
   </div>

  </div>
  <div class="example" id="example-3">
   <p><strong>Приклад #3 <span class="classname"><a href="class.yaf-route-regex.php" class="classname">Yaf_Route_Regex</a></span> using a named capture group</strong></p>
   <div class="example-contents">
<div class="phpcode"><pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php

</span><span style="color: #FF8000">/**
 * Use a named capture group as the controller name
 */
</span><span style="color: #0000BB">Yaf_Dispatcher</span><span style="color: #007700">::</span><span style="color: #0000BB">getInstance</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">getRouter</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">addRoute</span><span style="color: #007700">(
    </span><span style="color: #DD0000">"name"</span><span style="color: #007700">,
    new </span><span style="color: #0000BB">Yaf_Route_Regex</span><span style="color: #007700">(
        </span><span style="color: #DD0000">"#^/product/(?&lt;name&gt;[^/]+)/([^/]+)#i"</span><span style="color: #007700">, </span><span style="color: #FF8000">// match a URI leading "/product"
        </span><span style="color: #007700">array(
            </span><span style="color: #DD0000">'controller' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">":name"</span><span style="color: #007700">, </span><span style="color: #FF8000">// the "name" capture becomes the controller
        </span><span style="color: #007700">),
        array(
            </span><span style="color: #0000BB">2 </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"id"</span><span style="color: #007700">, </span><span style="color: #FF8000">// group 1 is named, only group 2 needs a map entry
        </span><span style="color: #007700">)
    )
);
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
   </div>

  </div>
  <div class="example" id="example-4">
   <p><strong>Приклад #4 <span class="classname"><a href="class.yaf-route-regex.php" class="classname">Yaf_Route_Regex</a></span> via <span class="methodname"><a href="yaf-router.addconfig.php" class="methodname">Yaf_Router::addConfig()</a></span></strong></p>
   <div class="example-contents">
<div class="phpcode"><pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php

</span><span style="color: #FF8000">/**
 * Add a regex route to the Yaf_Router route stack through a config array
 */
</span><span style="color: #0000BB">$config </span><span style="color: #007700">= array(
    </span><span style="color: #DD0000">"name" </span><span style="color: #007700">=&gt; array(
        </span><span style="color: #DD0000">"type"  </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"regex"</span><span style="color: #007700">,          </span><span style="color: #FF8000">// a Yaf_Route_Regex route
        </span><span style="color: #DD0000">"match" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"#(.*)#"</span><span style="color: #007700">,         </span><span style="color: #FF8000">// match any request URI
        </span><span style="color: #DD0000">"route" </span><span style="color: #007700">=&gt; array(
            </span><span style="color: #DD0000">'controller' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"product"</span><span style="color: #007700">, </span><span style="color: #FF8000">// route to the product controller
            </span><span style="color: #DD0000">'action'     </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"dummy"</span><span style="color: #007700">,   </span><span style="color: #FF8000">// and to the dummy action
        </span><span style="color: #007700">),
        </span><span style="color: #DD0000">"map" </span><span style="color: #007700">=&gt; array(
            </span><span style="color: #0000BB">1 </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"uri"</span><span style="color: #007700">, </span><span style="color: #FF8000">// $request-&gt;getParam("uri") holds the matched URI
        </span><span style="color: #007700">),
    ),
);

</span><span style="color: #0000BB">Yaf_Dispatcher</span><span style="color: #007700">::</span><span style="color: #0000BB">getInstance</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">getRouter</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">addConfig</span><span style="color: #007700">(
    new </span><span style="color: #0000BB">Yaf_Config_Simple</span><span style="color: #007700">(</span><span style="color: #0000BB">$config</span><span style="color: #007700">)
);
</span><span style="color: #0000BB">?&gt;</span></code></pre></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-yaf-route-regex.construct-seealso">
  <h3 class="title">Прогляньте також</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="yaf-route-regex.route.php" class="methodname" rel="rdfs-seeAlso">Yaf_Route_Regex::route()</a> - Route a request</span></li>
   <li><span class="methodname"><a href="yaf-route-regex.assemble.php" class="methodname" rel="rdfs-seeAlso">Yaf_Route_Regex::assemble()</a> - Assemble a url</span></li>
   <li><span class="methodname"><a href="yaf-router.addroute.php" class="methodname" rel="rdfs-seeAlso">Yaf_Router::addRoute()</a> - Add new Route into Router</span></li>
   <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-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); ?>