64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace LivraisonParSecteurs\Hook;
|
|
|
|
use LivraisonParSecteurs\LivraisonParSecteurs;
|
|
use Thelia\Core\Event\Hook\HookRenderEvent;
|
|
use Thelia\Core\Hook\BaseHook;
|
|
use Thelia\Core\Security\AccessManager;
|
|
use Thelia\Core\Security\SecurityContext;
|
|
|
|
/**
|
|
* Class AdminHook
|
|
*/
|
|
class AdminHook extends BaseHook
|
|
{
|
|
protected $securityContext;
|
|
|
|
public function __construct(SecurityContext $securityContext)
|
|
{
|
|
$this->securityContext = $securityContext;
|
|
}
|
|
|
|
public function onModuleConfig(HookRenderEvent $event)
|
|
{
|
|
$isGranted = $this->securityContext->isGranted(
|
|
["ADMIN"],
|
|
[],
|
|
[LivraisonParSecteurs::getModuleCode()],
|
|
[AccessManager::VIEW]
|
|
);
|
|
|
|
if ($isGranted) {
|
|
$event->add($this->render("deliveryarea-list.html", $event->getArguments()));
|
|
}
|
|
}
|
|
|
|
public function displayDeliveryDate(HookRenderEvent $event)
|
|
{
|
|
|
|
$moduleId = $event->getArgument('module');
|
|
$orderId = $event->getArgument('order_id');
|
|
|
|
if ((null !== $orderId) && ($moduleId == LivraisonParSecteurs::getModuleId()))
|
|
{
|
|
$selectedDay = $this->getSession()->get(LivraisonParSecteurs::LPS_DELIVERY_DATE);
|
|
$beginTime = $this->getSession()->get(LivraisonParSecteurs::LPS_DELIVERY_BEGIN_TIME);
|
|
$endTime = $this->getSession()->get(LivraisonParSecteurs::LPS_DELIVERY_END_TIME);
|
|
|
|
if ( (null !== $selectedDay) && (null !== $beginTime) && (null !== $endTime) )
|
|
{
|
|
$event->add(
|
|
$this->render(
|
|
'delivery-address.html', [
|
|
'day' => $selectedDay,
|
|
'begin_time' => $beginTime,
|
|
'end_time' => $endTime
|
|
])
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|