Quelques corrections + init du module ClickAndCollect
This commit is contained in:
82
local/modules/ClickAndCollect/Hook/AdminHook.php
Normal file
82
local/modules/ClickAndCollect/Hook/AdminHook.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace ClickAndCollect\Hook;
|
||||
|
||||
use ClickAndCollect\ClickAndCollect;
|
||||
use Thelia\Core\Event\Hook\HookRenderBlockEvent;
|
||||
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 onMainTopMenuTools(HookRenderEvent $event)
|
||||
{
|
||||
$isGranted = $this->securityContext->isGranted(
|
||||
["ADMIN"],
|
||||
[],
|
||||
[ClickAndCollect::getModuleCode()],
|
||||
[AccessManager::VIEW]
|
||||
);
|
||||
|
||||
if ($isGranted) {
|
||||
$event->add($this->render("menu-hook.html", $event->getArguments()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Pour afficher la liste des retraits en Click and Collect, dans la page d'accueil backOffice */
|
||||
public function displayScheduledWithdrawals(HookRenderBlockEvent $event)
|
||||
{
|
||||
$content = trim($this->render("scheduled-clickandcollect.html"));
|
||||
if (!empty($content)) {
|
||||
$event->add([
|
||||
"id" => "block-scheduled-clickandcollect",
|
||||
"title" => $this->trans("Scheduled click and collect", [], ClickAndCollect::DOMAIN_NAME),
|
||||
"content" => $content,
|
||||
"class" => "col-md-6"
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Pour intégrer la date de retrait possible dans différents formulaires (email, backOffice, ...) */
|
||||
public function displayDeliveryDate(HookRenderEvent $event)
|
||||
{
|
||||
|
||||
$moduleId = $event->getArgument('module');
|
||||
$orderId = $event->getArgument('order_id');
|
||||
|
||||
if ((null !== $orderId) && ($moduleId == ClickAndCollect::getModuleId()))
|
||||
{
|
||||
$sessionData = $this->getSession()->get('cncData');
|
||||
$selectedDay = $sessionData->getDeliveryDate();
|
||||
$beginTime = $sessionData->getDeliveryStartTime();
|
||||
$endTime = $sessionData->getDeliveryEndTime();
|
||||
|
||||
if ( (null !== $selectedDay) && (null !== $beginTime) && (null !== $endTime) )
|
||||
{
|
||||
$event->add(
|
||||
$this->render(
|
||||
'delivery-address.html', [
|
||||
'day' => $selectedDay,
|
||||
'begin_time' => $beginTime,
|
||||
'end_time' => $endTime
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user