|
@@ -146,7 +146,7 @@ discard block |
|
|
block discarded – undo |
|
146
|
146
|
$this->register(new MobileDetectServiceProvider()); |
|
147
|
147
|
|
|
148
|
148
|
$app = $this; |
|
149
|
|
- $this->error(function (\Exception $e, $code) use ($app) { |
|
|
149
|
+ $this->error(function(\Exception $e, $code) use ($app) { |
|
150
|
150
|
if ($app['debug']) { |
|
151
|
151
|
return; |
|
152
|
152
|
} |
|
@@ -217,7 +217,7 @@ discard block |
|
|
block discarded – undo |
|
217
|
217
|
'locale' => $this['config']['locale'], |
|
218
|
218
|
'translator.cache_dir' => $this['debug'] ? null : $this['config']['root_dir'].'/app/cache/translator', |
|
219
|
219
|
)); |
|
220
|
|
- $this['translator'] = $this->share($this->extend('translator', function ($translator, \Silex\Application $app) { |
|
|
220
|
+ $this['translator'] = $this->share($this->extend('translator', function($translator, \Silex\Application $app) { |
|
221
|
221
|
$translator->addLoader('yaml', new \Symfony\Component\Translation\Loader\YamlFileLoader()); |
|
222
|
222
|
|
|
223
|
223
|
$file = __DIR__.'/Resource/locale/validator.'.$app['locale'].'.yml'; |
|
@@ -264,14 +264,14 @@ discard block |
|
|
block discarded – undo |
|
264
|
264
|
$this->register(new \Silex\Provider\TwigServiceProvider(), array( |
|
265
|
265
|
'twig.form.templates' => array('Form/form_layout.twig'), |
|
266
|
266
|
)); |
|
267
|
|
- $this['twig'] = $this->share($this->extend('twig', function (\Twig_Environment $twig, \Silex\Application $app) { |
|
|
267
|
+ $this['twig'] = $this->share($this->extend('twig', function(\Twig_Environment $twig, \Silex\Application $app) { |
|
268
|
268
|
$twig->addExtension(new \Eccube\Twig\Extension\EccubeExtension($app)); |
|
269
|
269
|
$twig->addExtension(new \Twig_Extension_StringLoader()); |
|
270
|
270
|
|
|
271
|
271
|
return $twig; |
|
272
|
272
|
})); |
|
273
|
273
|
|
|
274
|
|
- $this->before(function (Request $request, \Silex\Application $app) { |
|
|
274
|
+ $this->before(function(Request $request, \Silex\Application $app) { |
|
275
|
275
|
$app['admin'] = false; |
|
276
|
276
|
$app['front'] = false; |
|
277
|
277
|
$pathinfo = rawurldecode($request->getPathInfo()); |
|
@@ -282,7 +282,7 @@ discard block |
|
|
block discarded – undo |
|
282
|
282
|
} |
|
283
|
283
|
|
|
284
|
284
|
// フロント or 管理画面ごとにtwigの探索パスを切り替える. |
|
285
|
|
- $app['twig'] = $app->share($app->extend('twig', function (\Twig_Environment $twig, \Silex\Application $app) { |
|
|
285
|
+ $app['twig'] = $app->share($app->extend('twig', function(\Twig_Environment $twig, \Silex\Application $app) { |
|
286
|
286
|
$paths = array(); |
|
287
|
287
|
|
|
288
|
288
|
// 互換性がないのでprofiler とproduction 時のcacheを分離する |
|
@@ -329,7 +329,7 @@ discard block |
|
|
block discarded – undo |
|
329
|
329
|
|
|
330
|
330
|
// twigのグローバル変数を定義. |
|
331
|
331
|
$app = $this; |
|
332
|
|
- $this->on(\Symfony\Component\HttpKernel\KernelEvents::CONTROLLER, function (\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event) use ($app) { |
|
|
332
|
+ $this->on(\Symfony\Component\HttpKernel\KernelEvents::CONTROLLER, function(\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event) use ($app) { |
|
333
|
333
|
// 未ログイン時にマイページや管理画面以下にアクセスするとSubRequestで実行されるため, |
|
334
|
334
|
// $event->isMasterRequest()ではなく、グローバル変数が初期化済かどうかの判定を行う |
|
335
|
335
|
if (isset($app['twig_global_initialized']) && $app['twig_global_initialized'] === true) { |
|
@@ -395,7 +395,7 @@ discard block |
|
|
block discarded – undo |
|
395
|
395
|
// メール送信時の文字エンコード指定(デフォルトはUTF-8) |
|
396
|
396
|
if (isset($this['config']['mail']['charset_iso_2022_jp']) && is_bool($this['config']['mail']['charset_iso_2022_jp'])) { |
|
397
|
397
|
if ($this['config']['mail']['charset_iso_2022_jp'] === true) { |
|
398
|
|
- \Swift::init(function () { |
|
|
398
|
+ \Swift::init(function() { |
|
399
|
399
|
\Swift_DependencyContainer::getInstance() |
|
400
|
400
|
->register('mime.qpheaderencoder') |
|
401
|
401
|
->asAliasOf('mime.base64headerencoder'); |
|
@@ -575,19 +575,19 @@ discard block |
|
|
block discarded – undo |
|
575
|
575
|
array('^/mypage', 'ROLE_USER', $channel), |
|
576
|
576
|
); |
|
577
|
577
|
|
|
578
|
|
- $this['eccube.password_encoder'] = $this->share(function ($app) { |
|
|
578
|
+ $this['eccube.password_encoder'] = $this->share(function($app) { |
|
579
|
579
|
return new \Eccube\Security\Core\Encoder\PasswordEncoder($app['config']); |
|
580
|
580
|
}); |
|
581
|
|
- $this['security.encoder_factory'] = $this->share(function ($app) { |
|
|
581
|
+ $this['security.encoder_factory'] = $this->share(function($app) { |
|
582
|
582
|
return new \Symfony\Component\Security\Core\Encoder\EncoderFactory(array( |
|
583
|
583
|
'Eccube\Entity\Customer' => $app['eccube.password_encoder'], |
|
584
|
584
|
'Eccube\Entity\Member' => $app['eccube.password_encoder'], |
|
585
|
585
|
)); |
|
586
|
586
|
}); |
|
587
|
|
- $this['eccube.event_listner.security'] = $this->share(function ($app) { |
|
|
587
|
+ $this['eccube.event_listner.security'] = $this->share(function($app) { |
|
588
|
588
|
return new \Eccube\EventListener\SecurityEventListener($app['orm.em']); |
|
589
|
589
|
}); |
|
590
|
|
- $this['user'] = function ($app) { |
|
|
590
|
+ $this['user'] = function($app) { |
|
591
|
591
|
$token = $app['security']->getToken(); |
|
592
|
592
|
|
|
593
|
593
|
return ($token !== null) ? $token->getUser() : null; |
|
@@ -598,17 +598,17 @@ discard block |
|
|
block discarded – undo |
|
598
|
598
|
|
|
599
|
599
|
// Voterの設定 |
|
600
|
600
|
$app = $this; |
|
601
|
|
- $this['authority_voter'] = $this->share(function ($app) { |
|
|
601
|
+ $this['authority_voter'] = $this->share(function($app) { |
|
602
|
602
|
return new \Eccube\Security\Voter\AuthorityVoter($app); |
|
603
|
603
|
}); |
|
604
|
604
|
|
|
605
|
|
- $app['security.voters'] = $app->extend('security.voters', function ($voters) use ($app) { |
|
|
605
|
+ $app['security.voters'] = $app->extend('security.voters', function($voters) use ($app) { |
|
606
|
606
|
$voters[] = $app['authority_voter']; |
|
607
|
607
|
|
|
608
|
608
|
return $voters; |
|
609
|
609
|
}); |
|
610
|
610
|
|
|
611
|
|
- $this['security.access_manager'] = $this->share(function ($app) { |
|
|
611
|
+ $this['security.access_manager'] = $this->share(function($app) { |
|
612
|
612
|
return new \Symfony\Component\Security\Core\Authorization\AccessDecisionManager($app['security.voters'], 'unanimous'); |
|
613
|
613
|
}); |
|
614
|
614
|
|
|
@@ -621,7 +621,7 @@ discard block |
|
|
block discarded – undo |
|
621
|
621
|
{ |
|
622
|
622
|
$config = $this['config']; |
|
623
|
623
|
if (isset($config['trusted_proxies_connection_only']) && !empty($config['trusted_proxies_connection_only'])) { |
|
624
|
|
- $this->on(KernelEvents::REQUEST, function (GetResponseEvent $event) use ($config) { |
|
|
624
|
+ $this->on(KernelEvents::REQUEST, function(GetResponseEvent $event) use ($config) { |
|
625
|
625
|
// サブリクエストのREMOTE_ADDRも動的に設定を行う必要があるため、KernelEvents::REQUESTを使用する |
|
626
|
626
|
Request::setTrustedProxies(array_merge(array($event->getRequest()->server->get('REMOTE_ADDR')), $config['trusted_proxies'])); |
|
627
|
627
|
}, self::EARLY_EVENT); |
|
@@ -648,14 +648,14 @@ discard block |
|
|
block discarded – undo |
|
648
|
648
|
public function initPluginEventDispatcher() |
|
649
|
649
|
{ |
|
650
|
650
|
// EventDispatcher |
|
651
|
|
- $this['eccube.event.dispatcher'] = $this->share(function () { |
|
|
651
|
+ $this['eccube.event.dispatcher'] = $this->share(function() { |
|
652
|
652
|
return new EventDispatcher(); |
|
653
|
653
|
}); |
|
654
|
654
|
|
|
655
|
655
|
$app = $this; |
|
656
|
656
|
|
|
657
|
657
|
// hook point |
|
658
|
|
- $this->on(KernelEvents::REQUEST, function (GetResponseEvent $event) use ($app) { |
|
|
658
|
+ $this->on(KernelEvents::REQUEST, function(GetResponseEvent $event) use ($app) { |
|
659
|
659
|
if (!$event->isMasterRequest()) { |
|
660
|
660
|
return; |
|
661
|
661
|
} |
|
@@ -663,7 +663,7 @@ discard block |
|
|
block discarded – undo |
|
663
|
663
|
$app['eccube.event.dispatcher']->dispatch($hookpoint, $event); |
|
664
|
664
|
}, self::EARLY_EVENT); |
|
665
|
665
|
|
|
666
|
|
- $this->on(KernelEvents::REQUEST, function (GetResponseEvent $event) use ($app) { |
|
|
666
|
+ $this->on(KernelEvents::REQUEST, function(GetResponseEvent $event) use ($app) { |
|
667
|
667
|
if (!$event->isMasterRequest()) { |
|
668
|
668
|
return; |
|
669
|
669
|
} |
|
@@ -672,7 +672,7 @@ discard block |
|
|
block discarded – undo |
|
672
|
672
|
$app['eccube.event.dispatcher']->dispatch($hookpoint, $event); |
|
673
|
673
|
}); |
|
674
|
674
|
|
|
675
|
|
- $this->on(KernelEvents::RESPONSE, function (FilterResponseEvent $event) use ($app) { |
|
|
675
|
+ $this->on(KernelEvents::RESPONSE, function(FilterResponseEvent $event) use ($app) { |
|
676
|
676
|
if (!$event->isMasterRequest()) { |
|
677
|
677
|
return; |
|
678
|
678
|
} |
|
@@ -681,7 +681,7 @@ discard block |
|
|
block discarded – undo |
|
681
|
681
|
$app['eccube.event.dispatcher']->dispatch($hookpoint, $event); |
|
682
|
682
|
}); |
|
683
|
683
|
|
|
684
|
|
- $this->on(KernelEvents::RESPONSE, function (FilterResponseEvent $event) use ($app) { |
|
|
684
|
+ $this->on(KernelEvents::RESPONSE, function(FilterResponseEvent $event) use ($app) { |
|
685
|
685
|
if (!$event->isMasterRequest()) { |
|
686
|
686
|
return; |
|
687
|
687
|
} |
|
@@ -689,13 +689,13 @@ discard block |
|
|
block discarded – undo |
|
689
|
689
|
$app['eccube.event.dispatcher']->dispatch($hookpoint, $event); |
|
690
|
690
|
}, self::LATE_EVENT); |
|
691
|
691
|
|
|
692
|
|
- $this->on(KernelEvents::TERMINATE, function (PostResponseEvent $event) use ($app) { |
|
|
692
|
+ $this->on(KernelEvents::TERMINATE, function(PostResponseEvent $event) use ($app) { |
|
693
|
693
|
$route = $event->getRequest()->attributes->get('_route'); |
|
694
|
694
|
$hookpoint = "eccube.event.controller.$route.finish"; |
|
695
|
695
|
$app['eccube.event.dispatcher']->dispatch($hookpoint, $event); |
|
696
|
696
|
}); |
|
697
|
697
|
|
|
698
|
|
- $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function (\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) { |
|
|
698
|
+ $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function(\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) { |
|
699
|
699
|
if (!$event->isMasterRequest()) { |
|
700
|
700
|
return; |
|
701
|
701
|
} |
|
@@ -704,7 +704,7 @@ discard block |
|
|
block discarded – undo |
|
704
|
704
|
}); |
|
705
|
705
|
|
|
706
|
706
|
// Request Event |
|
707
|
|
- $this->on(\Symfony\Component\HttpKernel\KernelEvents::REQUEST, function (\Symfony\Component\HttpKernel\Event\GetResponseEvent $event) use ($app) { |
|
|
707
|
+ $this->on(\Symfony\Component\HttpKernel\KernelEvents::REQUEST, function(\Symfony\Component\HttpKernel\Event\GetResponseEvent $event) use ($app) { |
|
708
|
708
|
|
|
709
|
709
|
if (!$event->isMasterRequest()) { |
|
710
|
710
|
return; |
|
@@ -735,7 +735,7 @@ discard block |
|
|
block discarded – undo |
|
735
|
735
|
}, 30); // Routing(32)が解決しし, 認証判定(8)が実行される前のタイミング. |
|
736
|
736
|
|
|
737
|
737
|
// Controller Event |
|
738
|
|
- $this->on(\Symfony\Component\HttpKernel\KernelEvents::CONTROLLER, function (\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event) use ($app) { |
|
|
738
|
+ $this->on(\Symfony\Component\HttpKernel\KernelEvents::CONTROLLER, function(\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event) use ($app) { |
|
739
|
739
|
|
|
740
|
740
|
if (!$event->isMasterRequest()) { |
|
741
|
741
|
return; |
|
@@ -765,7 +765,7 @@ discard block |
|
|
block discarded – undo |
|
765
|
765
|
}); |
|
766
|
766
|
|
|
767
|
767
|
// Response Event |
|
768
|
|
- $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function (\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) { |
|
|
768
|
+ $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function(\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) { |
|
769
|
769
|
if (!$event->isMasterRequest()) { |
|
770
|
770
|
return; |
|
771
|
771
|
} |
|
@@ -794,7 +794,7 @@ discard block |
|
|
block discarded – undo |
|
794
|
794
|
}); |
|
795
|
795
|
|
|
796
|
796
|
// Exception Event |
|
797
|
|
- $this->on(\Symfony\Component\HttpKernel\KernelEvents::EXCEPTION, function (\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event) use ($app) { |
|
|
797
|
+ $this->on(\Symfony\Component\HttpKernel\KernelEvents::EXCEPTION, function(\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event) use ($app) { |
|
798
|
798
|
|
|
799
|
799
|
if (!$event->isMasterRequest()) { |
|
800
|
800
|
return; |
|
@@ -824,7 +824,7 @@ discard block |
|
|
block discarded – undo |
|
824
|
824
|
}); |
|
825
|
825
|
|
|
826
|
826
|
// Terminate Event |
|
827
|
|
- $this->on(\Symfony\Component\HttpKernel\KernelEvents::TERMINATE, function (\Symfony\Component\HttpKernel\Event\PostResponseEvent $event) use ($app) { |
|
|
827
|
+ $this->on(\Symfony\Component\HttpKernel\KernelEvents::TERMINATE, function(\Symfony\Component\HttpKernel\Event\PostResponseEvent $event) use ($app) { |
|
828
|
828
|
|
|
829
|
829
|
$route = $event->getRequest()->attributes->get('_route'); |
|
830
|
830
|
|
|
@@ -895,7 +895,7 @@ discard block |
|
|
block discarded – undo |
|
895
|
895
|
|
|
896
|
896
|
// const |
|
897
|
897
|
if (isset($config['const'])) { |
|
898
|
|
- $this['config'] = $this->share($this->extend('config', function ($eccubeConfig) use ($config) { |
|
|
898
|
+ $this['config'] = $this->share($this->extend('config', function($eccubeConfig) use ($config) { |
|
899
|
899
|
$eccubeConfig[$config['code']] = array( |
|
900
|
900
|
'const' => $config['const'], |
|
901
|
901
|
); |
|
@@ -1098,7 +1098,7 @@ discard block |
|
|
block discarded – undo |
|
1098
|
1098
|
$app = $this; |
|
1099
|
1099
|
|
|
1100
|
1100
|
// Response Event(http cache対応、event実行は一番遅く設定) |
|
1101
|
|
- $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function (\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) { |
|
|
1101
|
+ $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function(\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) { |
|
1102
|
1102
|
|
|
1103
|
1103
|
if (!$event->isMasterRequest()) { |
|
1104
|
1104
|
return; |