<?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 => 'fr',
  ),
  'this' => 
  array (
    0 => 'yaf-plugin-abstract.predispatch.php',
    1 => 'Yaf_Plugin_Abstract::preDispatch',
    2 => 'Hook avant chaque distribution',
  ),
  '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' => 'fr',
    '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 avant chaque distribution</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">Ce hook est déclenché avant chaque itération de distribution dans la boucle de distribution. Une boucle de distribution peut effectuer plusieurs itérations, ce hook peut donc être appelé plusieurs fois par requête.</p>
 </div>


 <div class="refsect1 parameters" id="refsect1-yaf-plugin-abstract.predispatch-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <dl>
   
    <dt><code class="parameter">request</code></dt>
    <dd>
<p class="simpara">L&#039;instance de <span class="classname"><a href="class.yaf-request-abstract.php" class="classname">Yaf_Request_Abstract</a></span> en cours de distribution.</p>
    </dd>
   
   
    <dt><code class="parameter">response</code></dt>
    <dd>
<p class="simpara">L&#039;instance de <span class="classname"><a href="class.yaf-response-abstract.php" class="classname">Yaf_Response_Abstract</a></span>.</p>
    </dd>
   
  </dl>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-yaf-plugin-abstract.predispatch-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
<p class="simpara">Aucune valeur n&#039;est retournée.</p>
 </div>


 <div class="refsect1 examples" id="refsect1-yaf-plugin-abstract.predispatch-examples">
  <h3 class="title">Exemples</h3>
  <div class="example" id="example-1">
   <p><strong>Exemple #1 Exemple avec <span class="methodname"><strong>Yaf_Plugin_Abstract::preDispatch()</strong></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: #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">/* choix du répertoire de templates en fonction du module,
         * juste avant la distribution de l'action */
        </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">/* les plugins sont enregistrés dans le 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">Voir aussi</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> - Point d'accroche avant le routage</span></li>
   <li><span class="methodname"><a href="yaf-plugin-abstract.routershutdown.php" class="methodname" rel="rdfs-seeAlso">Yaf_Plugin_Abstract::routerShutdown()</a> - Point d'accroche apr&egrave;s le routage</span></li>
   <li><span class="methodname"><a href="yaf-plugin-abstract.dispatchloopstartup.php" class="methodname" rel="rdfs-seeAlso">Yaf_Plugin_Abstract::dispatchLoopStartup()</a> - Hook avant la boucle de distribution</span></li>
   <li><span class="methodname"><a href="yaf-plugin-abstract.postdispatch.php" class="methodname" rel="rdfs-seeAlso">Yaf_Plugin_Abstract::postDispatch()</a> - Hook apr&egrave;s chaque distribution</span></li>
   <li><span class="methodname"><a href="yaf-plugin-abstract.dispatchloopshutdown.php" class="methodname" rel="rdfs-seeAlso">Yaf_Plugin_Abstract::dispatchLoopShutdown()</a> - Hook apr&egrave;s la boucle de distribution</span></li>
   <li><span class="methodname"><a href="yaf-plugin-abstract.preresponse.php" class="methodname" rel="rdfs-seeAlso">Yaf_Plugin_Abstract::preResponse()</a> - Point d'accroche avant l'envoi de la r&eacute;ponse</span></li>
  </ul>
 </div>

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