local/modules/FairDelivery/Hook/FrontHook.php line 22
<?php
namespace FairDelivery\Hook;
use FairDelivery\FairDelivery;
use HookFetes\Model\AgendaFetesQuery;
use Thelia\Core\Event\Hook\HookRenderEvent;
use Thelia\Core\Hook\BaseHook;
/**
* Class FrontHook
* @package FairDelivery\Hook
* @author François Carfantan <f.carfantan@orange.fr>
*/
class FrontHook extends BaseHook {
public function onOrderDeliveryFormBottom(HookRenderEvent $event ){
$htmlContent = $this->render('fairs.html');
$event->add($htmlContent);
}
public function onOrderDeliveryJavaScript(HookRenderEvent $event){
if ($this->checkModule($event->getArgument('module'))){
$htmlContent = $this->render('fairsjs.html',['module_id'=>$event->getArgument('module')]);
$event->add($htmlContent);
}
}
public function onOrderInvoiceDeliveryAddress(HookRenderEvent $event){
// stocké dans la session à partir du listener
$fairId = $this->getRequest()->getSession()->get('fair_id');
if(is_null($fairId)) return;
$selectedFair = AgendaFetesQuery::create()->findOneByFetesId(intval($fairId));
$html = $this->render('invoicefairs.html',['fair_title'=>$selectedFair->getTitle()]);
$event->add($html);
}
protected function checkModule($currentModule):bool{
$module_id = FairDelivery::getModuleId();
if (strcmp($currentModule,$module_id)==0){
return true;
}
return false;
}
public static function getSubscribedHooks():array
{
return [
"order-delivery.form-bottom" => [
[
"type" => "front",
"method" => "onOrderDeliveryFormBottom"
]
],
"order-delivery.javascript" => [
[
"type" => "front",
"method" => "onOrderDeliveryJavaScript"
]
],
"order-invoice.delivery-address" => [
[
"type" => "front",
"method" => "onOrderInvoiceDeliveryAddress"
]
]
];
}
}
?>