These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of EC-CUBE |
||
5 | * |
||
6 | * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. |
||
7 | * |
||
8 | * http://www.ec-cube.co.jp/ |
||
9 | * |
||
10 | * For the full copyright and license information, please view the LICENSE |
||
11 | * file that was distributed with this source code. |
||
12 | */ |
||
13 | |||
14 | namespace Eccube\EventListener; |
||
15 | |||
16 | use Eccube\Common\EccubeConfig; |
||
17 | use Eccube\Request\Context; |
||
18 | use SunCat\MobileDetectBundle\DeviceDetector\MobileDetector; |
||
19 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
||
20 | use Symfony\Component\HttpKernel\Event\GetResponseEvent; |
||
21 | use Twig\Environment; |
||
22 | |||
23 | class MobileTemplatePathListener implements EventSubscriberInterface |
||
24 | { |
||
25 | /** |
||
26 | * @var Context |
||
27 | */ |
||
28 | protected $context; |
||
29 | |||
30 | /** |
||
31 | * @var Environment |
||
32 | */ |
||
33 | protected $twig; |
||
34 | |||
35 | /** |
||
36 | * @var MobileDetector |
||
37 | */ |
||
38 | protected $detector; |
||
39 | |||
40 | /** |
||
41 | * @var EccubeConfig |
||
42 | */ |
||
43 | protected $eccubeConfig; |
||
44 | |||
45 | 436 | public function __construct(Context $context, Environment $twig, MobileDetector $detector, EccubeConfig $eccubeConfig) |
|
46 | { |
||
47 | 436 | $this->context = $context; |
|
48 | 436 | $this->twig = $twig; |
|
49 | 436 | $this->detector = $detector; |
|
50 | 436 | $this->eccubeConfig = $eccubeConfig; |
|
51 | } |
||
52 | |||
53 | 436 | public function onKernelRequest(GetResponseEvent $event) |
|
54 | { |
||
55 | 436 | if (!$event->isMasterRequest()) { |
|
56 | 118 | return; |
|
57 | } |
||
58 | // 管理画面の場合は実行しない. |
||
59 | 436 | if ($this->context->isAdmin()) { |
|
60 | 278 | return; |
|
61 | } |
||
62 | |||
63 | 158 | if (!$this->detector->isMobile()) { |
|
64 | 158 | return; |
|
65 | } |
||
66 | |||
67 | $paths = [ |
||
68 | $this->eccubeConfig->get('eccube_theme_src_dir').'/smartphone', |
||
69 | ]; |
||
70 | |||
71 | if (is_dir($this->eccubeConfig->get('eccube_theme_app_dir').'/smartphone')) { |
||
72 | $paths = [ |
||
73 | $this->eccubeConfig->get('eccube_theme_app_dir').'/smartphone', |
||
74 | $this->eccubeConfig->get('eccube_theme_src_dir').'/smartphone', |
||
75 | ]; |
||
76 | } |
||
77 | |||
78 | $loader = new \Twig_Loader_Chain([ |
||
0 ignored issues
–
show
|
|||
79 | new \Twig_Loader_Filesystem($paths), |
||
0 ignored issues
–
show
The class
Twig_Loader_Filesystem has been deprecated with message: since Twig 2.7, use "Twig\Loader\FilesystemLoader" instead
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. ![]() |
|||
80 | $this->twig->getLoader(), |
||
81 | ]); |
||
82 | |||
83 | $this->twig->setLoader($loader); |
||
84 | } |
||
85 | |||
86 | 1 | public static function getSubscribedEvents() |
|
87 | { |
||
88 | return [ |
||
89 | 1 | 'kernel.request' => ['onKernelRequest', 512], |
|
90 | ]; |
||
91 | } |
||
92 | } |
||
93 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.