app/Plugin/TwoFactorAuthCustomerEmail42/Event.php line 59

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Plugin\TwoFactorAuthCustomerEmail42;
  13. use Eccube\Event\TemplateEvent;
  14. use Plugin\TwoFactorAuthCustomer42\Repository\TwoFactorAuthTypeRepository;
  15. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  16. /**
  17.  * Class Event.
  18.  */
  19. class Event implements EventSubscriberInterface
  20. {
  21.     /**
  22.      * @var bool
  23.      */
  24.     private bool $hasActiveAuthType;
  25.     /**
  26.      * @var TwoFactorAuthTypeRepository
  27.      */
  28.     private $twoFactorAuthTypeRepository;
  29.     /**
  30.      * Event constructor.
  31.      *
  32.      * @throws \Exception
  33.      */
  34.     public function __construct(TwoFactorAuthTypeRepository $twoFactorAuthTypeRepository)
  35.     {
  36.         $this->twoFactorAuthTypeRepository $twoFactorAuthTypeRepository;
  37.         $this->hasActiveAuthType $twoFactorAuthTypeRepository->count(['isDisabled' => false]) > 0;
  38.     }
  39.     public static function getSubscribedEvents(): array
  40.     {
  41.         return [
  42.             'TwoFactorAuthCustomer42/Resource/template/default/tfa/select_type.twig' => 'onSelectTypeTwig',
  43.         ];
  44.     }
  45.     /**
  46.      * [/admin/setting/shop]表示の時のEvent Hook.
  47.      * SMS関連項目を追加する.
  48.      *
  49.      * @param TemplateEvent $event
  50.      */
  51.     public function onSelectTypeTwig(TemplateEvent $event)
  52.     {
  53.         $appEnabled = !is_null($this->twoFactorAuthTypeRepository->findOneBy(['isDisabled' => false'name' => 'APP']));
  54.         $smsEnabled = !is_null($this->twoFactorAuthTypeRepository->findOneBy(['isDisabled' => false'name' => 'SMS']));
  55.         // add 本人確認認証 twig
  56.         $twig 'TwoFactorAuthCustomerEmail42/Resource/template/default/select_type.twig';
  57.         $event->addSnippet($twig);
  58.         $event->setParameter('appEnabled'$appEnabled);
  59.         $event->setParameter('smsEnabled'$smsEnabled);
  60.     }
  61. }