43 lines
1009 B
PHP
43 lines
1009 B
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("secteurs.html", $event->getArguments()));
|
|
}
|
|
}
|
|
|
|
public function onModuleConfigJs(HookRenderEvent $event)
|
|
{
|
|
$event->add($this->render('script/livraisonparsecteurs-js.html'));
|
|
}
|
|
|
|
}
|