<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.yaf-plugin-abstract.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'yaf-plugin-abstract.routershutdown.php',
    1 => 'Yaf_Plugin_Abstract::routerShutdown',
    2 => 'Hook after routing',
  ),
  'up' => 
  array (
    0 => 'class.yaf-plugin-abstract.php',
    1 => 'Yaf_Plugin_Abstract',
  ),
  'prev' => 
  array (
    0 => 'yaf-plugin-abstract.preresponse.php',
    1 => 'Yaf_Plugin_Abstract::preResponse',
  ),
  'next' => 
  array (
    0 => 'yaf-plugin-abstract.routerstartup.php',
    1 => 'Yaf_Plugin_Abstract::routerStartup',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/yaf/yaf_plugin_abstract/routershutdown.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="yaf-plugin-abstract.routershutdown" class="refentry">
 <div class="refnamediv">
<h1 class="refname">Yaf_Plugin_Abstract::routerShutdown</h1>
<p class="verinfo">(Yaf &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">Yaf_Plugin_Abstract::routerShutdown</span> &mdash; <span class="dc-title">Hook after routing</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yaf-plugin-abstract.routershutdown-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">function</span> <span class="methodname"><strong>Yaf_Plugin_Abstract::routerShutdown</strong></span>(<span class="methodparam"><span class="type"><a href="class.yaf-request-abstract.php" class="type Yaf_Request_Abstract">Yaf_Request_Abstract</a></span> <code class="parameter">$request</code></span>, <span class="methodparam"><span class="type"><a href="class.yaf-response-abstract.php" class="type Yaf_Response_Abstract">Yaf_Response_Abstract</a></span> <code class="parameter">$response</code></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

  <p class="simpara">This hook is triggered after the routing process has finished and the controller and action names have been resolved, but before the dispatch loop starts. It is usually used for access control checks such as a login check, because the target controller and action are already known.</p>
 </div>


 <div class="refsect1 parameters" id="refsect1-yaf-plugin-abstract.routershutdown-parameters">
  <h3 class="title">Parameters</h3>
  <dl>
   
    <dt><code class="parameter">request</code></dt>
    <dd>
<p class="simpara">The <span class="classname"><a href="class.yaf-request-abstract.php" class="classname">Yaf_Request_Abstract</a></span> instance being dispatched.</p>
    </dd>
   
   
    <dt><code class="parameter">response</code></dt>
    <dd>
<p class="simpara">The <span class="classname"><a href="class.yaf-response-abstract.php" class="classname">Yaf_Response_Abstract</a></span> instance.</p>
    </dd>
   
  </dl>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-yaf-plugin-abstract.routershutdown-returnvalues">
  <h3 class="title">Return Values</h3>
<p class="simpara">No value is returned.</p>
 </div>


 <div class="refsect1 examples" id="refsect1-yaf-plugin-abstract.routershutdown-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-1">
   <p><strong>Example #1 <span class="methodname"><strong>Yaf_Plugin_Abstract::routerShutdown()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><pre><code style="color: #000000"><span style="color: #0000BB">&lt;?php
</span><span style="color: #007700">class </span><span style="color: #0000BB">AuthPlugin </span><span style="color: #007700">extends </span><span style="color: #0000BB">Yaf_Plugin_Abstract
</span><span style="color: #007700">{
    public function </span><span style="color: #0000BB">routerShutdown</span><span style="color: #007700">(</span><span style="color: #0000BB">Yaf_Request_Abstract $request</span><span style="color: #007700">, </span><span style="color: #0000BB">Yaf_Response_Abstract $response</span><span style="color: #007700">)
    {
        </span><span style="color: #FF8000">/* routing is done, so the target controller and action are
         * known: check whether the user may access them */
        </span><span style="color: #0000BB">$public </span><span style="color: #007700">= array(</span><span style="color: #DD0000">"Index" </span><span style="color: #007700">=&gt; array(</span><span style="color: #DD0000">"index"</span><span style="color: #007700">), </span><span style="color: #DD0000">"User" </span><span style="color: #007700">=&gt; array(</span><span style="color: #DD0000">"login"</span><span style="color: #007700">));

        </span><span style="color: #0000BB">$controller </span><span style="color: #007700">= </span><span style="color: #0000BB">$request</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getControllerName</span><span style="color: #007700">();
        </span><span style="color: #0000BB">$action </span><span style="color: #007700">= </span><span style="color: #0000BB">$request</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getActionName</span><span style="color: #007700">();

        if (isset(</span><span style="color: #0000BB">$public</span><span style="color: #007700">[</span><span style="color: #0000BB">$controller</span><span style="color: #007700">]) &amp;&amp; </span><span style="color: #0000BB">in_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$action</span><span style="color: #007700">, </span><span style="color: #0000BB">$public</span><span style="color: #007700">[</span><span style="color: #0000BB">$controller</span><span style="color: #007700">])) {
            return;
        }

        if (!</span><span style="color: #0000BB">Yaf_Session</span><span style="color: #007700">::</span><span style="color: #0000BB">getInstance</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">has</span><span style="color: #007700">(</span><span style="color: #DD0000">"login"</span><span style="color: #007700">)) {
            </span><span style="color: #0000BB">$response</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setRedirect</span><span style="color: #007700">(</span><span style="color: #DD0000">"/user/login"</span><span style="color: #007700">);
            </span><span style="color: #0000BB">$request</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setDispatched</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">); </span><span style="color: #FF8000">// do not dispatch the request
        </span><span style="color: #007700">}
    }
}

</span><span style="color: #FF8000">/* plugins are registered in the bootstrap */
</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">{
    public function </span><span style="color: #0000BB">_initPlugin</span><span style="color: #007700">(</span><span style="color: #0000BB">Yaf_Dispatcher $dispatcher</span><span style="color: #007700">)
    {
        </span><span style="color: #0000BB">$dispatcher</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">registerPlugin</span><span style="color: #007700">(new </span><span style="color: #0000BB">AuthPlugin</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-plugin-abstract.routershutdown-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="yaf-plugin-abstract.routerstartup.php" class="methodname" rel="rdfs-seeAlso">Yaf_Plugin_Abstract::routerStartup()</a> - Hook before routing</span></li>
   <li><span class="methodname"><a href="yaf-plugin-abstract.dispatchloopstartup.php" class="methodname" rel="rdfs-seeAlso">Yaf_Plugin_Abstract::dispatchLoopStartup()</a> - Hook before dispatch loop</span></li>
   <li><span class="methodname"><a href="yaf-plugin-abstract.predispatch.php" class="methodname" rel="rdfs-seeAlso">Yaf_Plugin_Abstract::preDispatch()</a> - Hook before each dispatch</span></li>
   <li><span class="methodname"><a href="yaf-plugin-abstract.postdispatch.php" class="methodname" rel="rdfs-seeAlso">Yaf_Plugin_Abstract::postDispatch()</a> - Hook after each dispatch</span></li>
   <li><span class="methodname"><a href="yaf-plugin-abstract.dispatchloopshutdown.php" class="methodname" rel="rdfs-seeAlso">Yaf_Plugin_Abstract::dispatchLoopShutdown()</a> - Hook after dispatch loop</span></li>
   <li><span class="methodname"><a href="yaf-plugin-abstract.preresponse.php" class="methodname" rel="rdfs-seeAlso">Yaf_Plugin_Abstract::preResponse()</a> - Hook before the response is sent</span></li>
  </ul>
 </div>

</div><?php manual_footer($setup); ?>