<?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.predispatch.php',
    1 => 'Yaf_Plugin_Abstract::preDispatch',
    2 => 'Hook before each dispatch',
  ),
  'up' => 
  array (
    0 => 'class.yaf-plugin-abstract.php',
    1 => 'Yaf_Plugin_Abstract',
  ),
  'prev' => 
  array (
    0 => 'yaf-plugin-abstract.postdispatch.php',
    1 => 'Yaf_Plugin_Abstract::postDispatch',
  ),
  'next' => 
  array (
    0 => 'yaf-plugin-abstract.preresponse.php',
    1 => 'Yaf_Plugin_Abstract::preResponse',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/yaf/yaf_plugin_abstract/predispatch.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="yaf-plugin-abstract.predispatch" class="refentry">
 <div class="refnamediv">
<h1 class="refname">Yaf_Plugin_Abstract::preDispatch</h1>
<p class="verinfo">(Yaf &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">Yaf_Plugin_Abstract::preDispatch</span> &mdash; <span class="dc-title">Hook before each dispatch</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yaf-plugin-abstract.predispatch-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::preDispatch</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 before each dispatch iteration in the dispatch loop. A dispatch loop may run several iterations, so this hook may be called more than once per request.</p>
 </div>


 <div class="refsect1 parameters" id="refsect1-yaf-plugin-abstract.predispatch-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.predispatch-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.predispatch-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-1">
   <p><strong>Example #1 <span class="methodname"><strong>Yaf_Plugin_Abstract::preDispatch()</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">LayoutPlugin </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">preDispatch</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">/* pick the template directory based on the module, right
         * before the action is dispatched */
        </span><span style="color: #0000BB">$view </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">getView</span><span style="color: #007700">();
        if (</span><span style="color: #0000BB">$request</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getModuleName</span><span style="color: #007700">() == </span><span style="color: #DD0000">"Admin"</span><span style="color: #007700">) {
            </span><span style="color: #0000BB">$view</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setScriptPath</span><span style="color: #007700">(</span><span style="color: #0000BB">APPLICATION_PATH </span><span style="color: #007700">. </span><span style="color: #DD0000">"/modules/admin/views"</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">LayoutPlugin</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.predispatch-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.routershutdown.php" class="methodname" rel="rdfs-seeAlso">Yaf_Plugin_Abstract::routerShutdown()</a> - Hook after 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.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); ?>