local/modules/FairDelivery/Hook/FrontHook.php line 22

  1. <?php
  2. namespace FairDelivery\Hook;
  3. use FairDelivery\FairDelivery;
  4. use HookFetes\Model\AgendaFetesQuery;
  5. use Thelia\Core\Event\Hook\HookRenderEvent;
  6. use Thelia\Core\Hook\BaseHook;
  7. /**
  8.  * Class FrontHook
  9.  * @package FairDelivery\Hook
  10.  * @author François Carfantan <f.carfantan@orange.fr>
  11.  */
  12. class FrontHook extends BaseHook {
  13.    
  14.     public function onOrderDeliveryFormBottom(HookRenderEvent $event ){
  15.             $htmlContent $this->render('fairs.html');
  16.             $event->add($htmlContent);
  17.          }
  18.          
  19.     public function onOrderDeliveryJavaScript(HookRenderEvent $event){
  20.          if ($this->checkModule($event->getArgument('module'))){
  21.             $htmlContent $this->render('fairsjs.html',['module_id'=>$event->getArgument('module')]);
  22.             $event->add($htmlContent);
  23.          }
  24.     }
  25.     public function onOrderInvoiceDeliveryAddress(HookRenderEvent $event){
  26.         // stocké dans la session à partir du listener
  27.         $fairId $this->getRequest()->getSession()->get('fair_id');
  28.         if(is_null($fairId)) return;
  29.         $selectedFair AgendaFetesQuery::create()->findOneByFetesId(intval($fairId));
  30.         $html $this->render('invoicefairs.html',['fair_title'=>$selectedFair->getTitle()]);
  31.         $event->add($html);
  32.     }
  33.    
  34.  
  35.   
  36.     protected function checkModule($currentModule):bool{
  37.         $module_id FairDelivery::getModuleId();
  38.         if (strcmp($currentModule,$module_id)==0){
  39.             return true;
  40.         }
  41.         return false;
  42.     }
  43.     public static function getSubscribedHooks():array
  44.     {
  45.         return [
  46.             "order-delivery.form-bottom" => [
  47.                 [
  48.                     "type" => "front",
  49.                     "method" => "onOrderDeliveryFormBottom"
  50.                 ]               
  51.                 ],
  52.             "order-delivery.javascript" => [
  53.                 [
  54.                     "type" => "front",
  55.                 "method" => "onOrderDeliveryJavaScript"
  56.                 ]
  57.                 
  58.             ],
  59.             "order-invoice.delivery-address" => [
  60.                 [
  61.                     "type" => "front",
  62.                     "method" => "onOrderInvoiceDeliveryAddress"
  63.                 ]
  64.                
  65.             ]
  66.                 ];
  67.            
  68.     }
  69. }
  70. ?>