app/Plugin/Taba2FA/EventListener/InitializeListener.php line 68

Open in your IDE?
  1. <?php
  2. /*
  3.  * Copyright (C) SPREAD WORKS Inc. All Rights Reserved.
  4.  *
  5.  * For the full copyright and license information, please view the LICENSE
  6.  * file that was distributed with this source code.
  7.  */
  8. namespace Plugin\Taba2FA\EventListener;
  9. use Plugin\Taba2FA\Common\Constants;
  10. use Plugin\Taba2FA\Common\UserConfig;
  11. use Symfony\Component\DependencyInjection\ContainerInterface;
  12. class InitializeListener
  13. {
  14.     /**
  15.      * @var ContainerInterface
  16.      */
  17.     private $container;
  18.     /**
  19.      * @var \Twig_Environment
  20.      */
  21.     private $twig;
  22.     /**
  23.      * コンストラクタ
  24.      *
  25.      * @param ContainerInterface $container
  26.      */
  27.     public function __construct(ContainerInterface $container,\Twig_Environment $twig)
  28.     {
  29.         $this->container $container;
  30.         $this->twig $twig;
  31.         // 設定ファイルの読み込み
  32.         UserConfig::getInstance()->load($this->container->getParameter('kernel.project_dir') . Constants::PLUGIN_DATA_DIR DIRECTORY_SEPARATOR Constants::USER_CONFIG_FILE);
  33.         $this->twig->addGlobal(Constants::PLUGIN_CODE.'UserConfig'UserConfig::getInstance());
  34.         // Twigグローバル変数セット
  35.         $this->twig->addGlobal(Constants::PLUGIN_CODE.'Constants', new Constants());
  36.         // コンテナにプラグイン間で共有するデータホルダーを登録します。
  37.         if (!$this->container->has(Constants::CONTAINER_KEY_NAME)) {
  38.             $this->container->set(
  39.                 Constants::CONTAINER_KEY_NAME,
  40.                 new class {
  41.                     private $data;
  42.                     public function set($key$val)
  43.                     {
  44.                         $this->data[$key] = $val;
  45.                     }
  46.                     public function get($key)
  47.                     {
  48.                         if (isset($this->data[$key])) return $this->data[$key];
  49.                         return null;
  50.                     }
  51.                 }
  52.             );
  53.         }
  54.     }
  55.     /**
  56.      * {@inheritDoc}
  57.      * @see \Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest()
  58.      */
  59.     public function onKernelRequest() {
  60.     }
  61. }