app/Customize/EventListener/MobileTemplatePathListener.php line 40

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 Customize\EventListener;
  13. use Eccube\Common\EccubeConfig;
  14. use Eccube\Request\Context;
  15. use Symfony\Component\HttpKernel\Event\GetResponseEvent;
  16. use Twig\Environment;
  17. use Customize\Service\MobileDetector as LmMobileDetector;
  18. class MobileTemplatePathListener extends \Eccube\EventListener\MobileTemplatePathListener
  19. {
  20.     public function __construct(
  21.         Context          $context,
  22.         Environment      $twig,
  23.         LmMobileDetector $detector,     // Warn: Customized.
  24.         EccubeConfig     $eccubeConfig
  25.     ) {
  26.         //
  27.         parent::__construct(
  28.             $context,
  29.             $twig,
  30.             $detector,          // Warn: Customized.
  31.             $eccubeConfig
  32.         );
  33.     }
  34.     public function onKernelRequest(GetResponseEvent $event)
  35.     {
  36.         if (!$this->detector->isMobile()) {
  37.             $baseLoader $this->twig->getLoader();
  38.             if ($baseLoader instanceof \Twig\Loader\ChainLoader) {
  39.                 foreach ($baseLoader->getLoaders() as $loader) {
  40.                     if ($loader instanceof \Symfony\Bundle\TwigBundle\Loader\FilesystemLoader) {
  41.                         $baseLoader $loader;
  42.                         break;
  43.                     }
  44.                 }
  45.             }
  46.             //
  47.             $this->twig->setLoader($baseLoader);
  48.         }
  49.     }
  50. }