app/Plugin/TabaHtmlEditor2/EventListener/InitializeListener.php line 70

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\TabaHtmlEditor2\EventListener;
  9. use Plugin\TabaHtmlEditor2\Common\Constants;
  10. use Plugin\TabaHtmlEditor2\Common\UserConfig;
  11. use Psr\Container\ContainerInterface;
  12. use Twig\Environment;
  13. class InitializeListener
  14. {
  15.     /**
  16.      * @var ContainerInterface
  17.      */
  18.     private $container;
  19.     /**
  20.      * @var Environment
  21.      */
  22.     private $twig;
  23.     /**
  24.      * コンストラクタ
  25.      *
  26.      * @param ContainerInterface $container
  27.      * @param Environment $twig
  28.      */
  29.     public function __construct(ContainerInterface $container,Environment $twig)
  30.     {
  31.         $this->container $container;
  32.         $this->twig $twig;
  33.         // 設定ファイルの読み込み
  34.         $eccubeConfig $container->get('Eccube\Common\EccubeConfig');
  35.         UserConfig::getInstance()->load($eccubeConfig->get('kernel.project_dir') . Constants::PLUGIN_DATA_DIR DIRECTORY_SEPARATOR Constants::USER_CONFIG_FILE);
  36.         $this->twig->addGlobal(Constants::PLUGIN_CODE.'UserConfig'UserConfig::getInstance());
  37.         // Twigグローバル変数セット
  38.         $this->twig->addGlobal(Constants::PLUGIN_CODE.'Constants', new Constants());
  39.         // コンテナにプラグイン間で共有するデータホルダーを登録します。
  40.         if (!$this->container->has(Constants::CONTAINER_KEY_NAME)) {
  41.             $this->container->set(
  42.                 Constants::CONTAINER_KEY_NAME,
  43.                 new class {
  44.                     private $data;
  45.                     public function set($key$val)
  46.                     {
  47.                         $this->data[$key] = $val;
  48.                     }
  49.                     public function get($key)
  50.                     {
  51.                         if (isset($this->data[$key])) return $this->data[$key];
  52.                         return null;
  53.                     }
  54.                 }
  55.             );
  56.         }
  57.     }
  58.     /**
  59.      * {@inheritDoc}
  60.      * @see \Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest()
  61.      */
  62.     public function onKernelRequest() {
  63.     }
  64. }