<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Customize\EventListener;
use Eccube\Common\EccubeConfig;
use Eccube\Request\Context;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Twig\Environment;
use Customize\Service\MobileDetector as LmMobileDetector;
class MobileTemplatePathListener extends \Eccube\EventListener\MobileTemplatePathListener
{
public function __construct(
Context $context,
Environment $twig,
LmMobileDetector $detector, // Warn: Customized.
EccubeConfig $eccubeConfig
) {
//
parent::__construct(
$context,
$twig,
$detector, // Warn: Customized.
$eccubeConfig
);
}
public function onKernelRequest(RequestEvent $event)
{
if (!$this->detector->isMobile()) {
$baseLoader = $this->twig->getLoader();
if ($baseLoader instanceof \Twig\Loader\ChainLoader) {
foreach ($baseLoader->getLoaders() as $loader) {
if ($loader instanceof \Symfony\Bundle\TwigBundle\Loader\FilesystemLoader) {
$baseLoader = $loader;
break;
}
}
}
//
$this->twig->setLoader($baseLoader);
}
}
}