Files
aux-bieaux-legumes/local/modules/PointRetrait/Hook/AdminHook.php

55 lines
1.4 KiB
PHP

<?php
namespace PointRetrait\Hook;
use PointRetrait\PointRetrait;
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"],
[],
[PointRetrait::getModuleCode()],
[AccessManager::VIEW]
);
if ($isGranted) {
$event->add($this->render("menu-hook.html", $event->getArguments()));
}
}
/* Pour afficher la liste des retraits en Point Retrait prévus dans la page d'accueil backOffice */
public function displayScheduledWithdrawals(HookRenderBlockEvent $event)
{
$content = trim($this->render("scheduled-withdrawals.html"));
if (!empty($content)) {
$event->add([
"id" => "block-scheduled-withdrawals",
"title" => $this->trans("Scheduled withdrawals", [], PointRetrait::DOMAIN_NAME),
"content" => $content,
"class" => "col-md-6"
]);
}
}
}