local/modules/TheliaGiftCard/Hook/HookManager.php line 36

Open in your IDE?
  1. <?php
  2. /*************************************************************************************/
  3. /*      Copyright (c) BERTRAND TOURLONIAS                                            */
  4. /*      email : btourlonias@openstudio.fr                                            */
  5. /*************************************************************************************/
  6. namespace TheliaGiftCard\Hook;
  7. use Thelia\Core\Event\Hook\HookRenderBlockEvent;
  8. use Thelia\Core\Event\Hook\HookRenderEvent;
  9. use Thelia\Core\Hook\BaseHook;
  10. use Thelia\Core\Security\AccessManager;
  11. use Thelia\Core\Security\SecurityContext;
  12. use Thelia\Tools\URL;
  13. use TheliaGiftCard\TheliaGiftCard;
  14. class HookManager extends BaseHook
  15. {
  16.     /*
  17.     * @var SecurityContext
  18.     */
  19.     private $securityContext;
  20.     public function __constructSecurityContext $securityContext)
  21.     {
  22.         $this->securityContext $securityContext;
  23.     }
  24.     public function cardGiftAccountUsageInOrder(HookRenderEvent $event)
  25.     {
  26.         $event->add(
  27.             $this->render("gift-card-usage-on-order.html", [ 'order_id' => $event->getArgument('order_id') ])
  28.         );
  29.     }
  30.     public function onMainTopMenuTools(HookRenderBlockEvent $event)
  31.     {
  32.         $isGranted $this->securityContext->isGranted(
  33.             ["ADMIN"],
  34.             ["admin.orders.lines.export"],
  35.             [TheliaGiftCard::getModuleCode()],
  36.             [AccessManager::VIEW]
  37.         );
  38.         if($isGranted) {
  39.             $event->add(
  40.                 [
  41.                     'id' => 'tools_menu_gidt_card',
  42.                     'class' => '',
  43.                     'url' => URL::getInstance()->absoluteUrl('/admin/module/TheliaGiftCard'),
  44.                     'title' => $this->trans('Gift Card Config', [], TheliaGiftCard::DOMAIN_NAME)
  45.                 ]
  46.             );
  47.         }
  48.     }
  49. }