Completed
Pull Request — experimental/3.1 (#2480)
by Kentaro
72:50 queued 16:33
created
src/Eccube/Application.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
         $this->register(new \Saxulum\Validator\Provider\SaxulumValidatorProvider());
171 171
         $this->register(new MobileDetectServiceProvider());
172 172
 
173
-        $this->error(function (\Exception $e, Request $request, $code) {
173
+        $this->error(function(\Exception $e, Request $request, $code) {
174 174
             if ($this['debug']) {
175 175
                 return;
176 176
             }
@@ -276,14 +276,14 @@  discard block
 block discarded – undo
276 276
             return $router;
277 277
         });
278 278
 
279
-        $this['eccube.router.origin'] = function ($app) {
279
+        $this['eccube.router.origin'] = function($app) {
280 280
             $resource = __DIR__.'/Controller';
281 281
             $cachePrefix = 'Origin';
282 282
 
283 283
             return $app['eccube.router']($resource, $cachePrefix);
284 284
         };
285 285
 
286
-        $this['eccube.routers.plugin'] = function ($app) {
286
+        $this['eccube.routers.plugin'] = function($app) {
287 287
             // TODO 有効なプラグインを対象とする必要がある.
288 288
             $dirs = Finder::create()
289 289
                 ->in($app['config']['root_dir'].'/app/Plugin')
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
             return $routers;
301 301
         };
302 302
 
303
-        $this['eccube.router.extend'] = function ($app) {
303
+        $this['eccube.router.extend'] = function($app) {
304 304
             // TODO ディレクトリ名は暫定
305 305
             $resource = $app['config']['root_dir'].'/app/Acme/Controller';
306 306
             $cachePrefix = 'Extend';
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
             return $router;
311 311
         };
312 312
 
313
-        $this->extend('request_matcher', function ($matcher, $app) {
313
+        $this->extend('request_matcher', function($matcher, $app) {
314 314
             $matchers = [];
315 315
             $matchers[] = $app['eccube.router.extend'];
316 316
             foreach ($app['eccube.routers.plugin'] as $router) {
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
             return new ChainUrlMatcher($matchers, $app['request_context']);
323 323
         });
324 324
 
325
-        $this->extend('url_generator', function ($generator, $app) {
325
+        $this->extend('url_generator', function($generator, $app) {
326 326
             $generators = [];
327 327
             $generators[] = $app['eccube.router.extend'];
328 328
             foreach ($app['eccube.routers.plugin'] as $router) {
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
         });
336 336
 
337 337
         // Route CollectionにEC-CUBEで定義したルーティングを追加(debug tool barに出力するため)
338
-        $this->extend('routes', function ($routes, $app) {
338
+        $this->extend('routes', function($routes, $app) {
339 339
             $routes->addCollection($app['eccube.router.extend']->getRouteCollection());
340 340
             foreach ($app['eccube.routers.plugin'] as $router) {
341 341
                 $routes->addCollection($router->getRouteCollection());
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
             'translator.cache_dir' => $this['debug'] ? null : $this['config']['root_dir'].'/app/cache/translator',
369 369
             'locale_fallbacks' => ['ja', 'en'],
370 370
         ));
371
-        $this->extend('translator', function ($translator, \Silex\Application $app) {
371
+        $this->extend('translator', function($translator, \Silex\Application $app) {
372 372
             $translator->addLoader('php', new \Symfony\Component\Translation\Loader\PhpFileLoader());
373 373
 
374 374
             $file = __DIR__.'/Resource/locale/messages.'.$app['locale'].'.php';
@@ -411,14 +411,14 @@  discard block
 block discarded – undo
411 411
         $this->register(new \Silex\Provider\TwigServiceProvider(), array(
412 412
             'twig.form.templates' => array('Form/form_layout.twig'),
413 413
         ));
414
-        $this->extend('twig', function (\Twig_Environment $twig, \Silex\Application $app) {
414
+        $this->extend('twig', function(\Twig_Environment $twig, \Silex\Application $app) {
415 415
             $twig->addExtension(new \Eccube\Twig\Extension\EccubeExtension($app));
416 416
             $twig->addExtension(new \Twig_Extension_StringLoader());
417 417
 
418 418
             return $twig;
419 419
         });
420 420
 
421
-        $this->before(function (Request $request, \Silex\Application $app) {
421
+        $this->before(function(Request $request, \Silex\Application $app) {
422 422
             $app['admin'] = $app['front'] = false;
423 423
             $pathinfo = rawurldecode($request->getPathInfo());
424 424
             if (strpos($pathinfo, '/'.trim($app['config']['admin_route'], '/').'/') === 0) {
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
                 }
435 435
                 $paths[] = $app['config']['template_admin_realdir'];
436 436
                 $paths[] = __DIR__.'/../../app/Plugin';
437
-                $cacheDir =  __DIR__.'/../../app/cache/twig/admin';
437
+                $cacheDir = __DIR__.'/../../app/cache/twig/admin';
438 438
             } else {
439 439
                 // モバイル端末時、smartphoneディレクトリを探索パスに追加する.
440 440
                 if ($app['mobile_detect.device_type'] == \Eccube\Entity\Master\DeviceType::DEVICE_TYPE_SP) {
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
                 }
450 450
                 $paths[] = $app['config']['template_default_realdir'];
451 451
                 $paths[] = __DIR__.'/../../app/Plugin';
452
-                $cacheDir =  __DIR__.'/../../app/cache/twig/'.$app['config']['template_code'];
452
+                $cacheDir = __DIR__.'/../../app/cache/twig/'.$app['config']['template_code'];
453 453
             }
454 454
             $app['twig']->setCache($app['debug'] ? null : $cacheDir);
455 455
             $app['twig.loader']->addLoader(new \Twig_Loader_Filesystem($paths));
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
         }, self::EARLY_EVENT);
468 468
 
469 469
         // twigのグローバル変数を定義.
470
-        $this->on(\Symfony\Component\HttpKernel\KernelEvents::CONTROLLER, function (\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event) {
470
+        $this->on(\Symfony\Component\HttpKernel\KernelEvents::CONTROLLER, function(\Symfony\Component\HttpKernel\Event\FilterControllerEvent $event) {
471 471
             // 未ログイン時にマイページや管理画面以下にアクセスするとSubRequestで実行されるため,
472 472
             // $event->isMasterRequest()ではなく、グローバル変数が初期化済かどうかの判定を行う
473 473
             if (isset($this['twig_global_initialized']) && $this['twig_global_initialized'] === true) {
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
         // メール送信時の文字エンコード指定(デフォルトはUTF-8)
554 554
         if (isset($this['config']['mail']['charset_iso_2022_jp']) && is_bool($this['config']['mail']['charset_iso_2022_jp'])) {
555 555
             if ($this['config']['mail']['charset_iso_2022_jp'] === true) {
556
-                \Swift::init(function () {
556
+                \Swift::init(function() {
557 557
                     \Swift_DependencyContainer::getInstance()
558 558
                         ->register('mime.qpheaderencoder')
559 559
                         ->asAliasOf('mime.base64headerencoder');
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
         $this->register(new \Saxulum\DoctrineOrmManagerRegistry\Provider\DoctrineOrmManagerRegistryProvider());
589 589
 
590 590
         $app = $this;
591
-        $this->extend('db.event_manager', function ($evm) use ($app) {
591
+        $this->extend('db.event_manager', function($evm) use ($app) {
592 592
             $initSubscriber = new InitSubscriber($app);
593 593
             $evm->addEventSubscriber($initSubscriber);
594 594
 
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 
684 684
         $this->extend(
685 685
             'orm.em.config',
686
-            function (\Doctrine\ORM\Configuration $config, \Silex\Application $app) {
686
+            function(\Doctrine\ORM\Configuration $config, \Silex\Application $app) {
687 687
 
688 688
                 /** @var $chain \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain */
689 689
                 $chain = $config->getMetadataDriverImpl();
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
             }
706 706
         );
707 707
 
708
-        $this->extend('orm.em', function (\Doctrine\ORM\EntityManager $em, \Silex\Application $app) {
708
+        $this->extend('orm.em', function(\Doctrine\ORM\EntityManager $em, \Silex\Application $app) {
709 709
             // save
710 710
             $saveEventSubscriber = new \Eccube\Doctrine\EventSubscriber\SaveEventSubscriber($app);
711 711
             $em->getEventManager()->addEventSubscriber($saveEventSubscriber);
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
             // second level cacheの設定.
729 729
             $this->extend(
730 730
                 'orm.em.config',
731
-                function (\Doctrine\ORM\Configuration $config, \Silex\Application $app) {
731
+                function(\Doctrine\ORM\Configuration $config, \Silex\Application $app) {
732 732
                     $config->setSecondLevelCacheEnabled();
733 733
                     $cacheConfig = $config->getSecondLevelCacheConfiguration();
734 734
                     $regionConfig = $cacheConfig->getRegionsConfiguration();
@@ -817,31 +817,31 @@  discard block
 block discarded – undo
817 817
             array('^/mypage', 'ROLE_USER', $channel),
818 818
         );
819 819
 
820
-        $this['eccube.password_encoder'] = function ($app) {
820
+        $this['eccube.password_encoder'] = function($app) {
821 821
             return new \Eccube\Security\Core\Encoder\PasswordEncoder($app['config']);
822 822
         };
823
-        $this['security.encoder_factory'] = function ($app) {
823
+        $this['security.encoder_factory'] = function($app) {
824 824
             return new \Symfony\Component\Security\Core\Encoder\EncoderFactory(array(
825 825
                 'Eccube\Entity\Customer' => $app['eccube.password_encoder'],
826 826
                 'Eccube\Entity\Member' => $app['eccube.password_encoder'],
827 827
             ));
828 828
         };
829
-        $this['eccube.event_listner.security'] = function ($app) {
829
+        $this['eccube.event_listner.security'] = function($app) {
830 830
             return new \Eccube\EventListener\SecurityEventListener($app['orm.em']);
831 831
         };
832 832
 
833 833
         // Voterの設定
834
-        $this['authority_voter'] = function ($app) {
834
+        $this['authority_voter'] = function($app) {
835 835
             return new \Eccube\Security\Voter\AuthorityVoter($app);
836 836
         };
837 837
 
838
-        $this->extend('security.voters', function ($voters, \Silex\Application $app) {
838
+        $this->extend('security.voters', function($voters, \Silex\Application $app) {
839 839
             $voters[] = $app['authority_voter'];
840 840
 
841 841
             return $voters;
842 842
         });
843 843
 
844
-        $this['security.access_manager'] = function ($app) {
844
+        $this['security.access_manager'] = function($app) {
845 845
             return new \Symfony\Component\Security\Core\Authorization\AccessDecisionManager($app['security.voters'], 'unanimous');
846 846
         };
847 847
 
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
     {
856 856
         $config = $this['config'];
857 857
         if (isset($config['trusted_proxies_connection_only']) && !empty($config['trusted_proxies_connection_only'])) {
858
-            $this->on(KernelEvents::REQUEST, function (GetResponseEvent $event) use ($config) {
858
+            $this->on(KernelEvents::REQUEST, function(GetResponseEvent $event) use ($config) {
859 859
                 // サブリクエストのREMOTE_ADDRも動的に設定を行う必要があるため、KernelEvents::REQUESTを使用する
860 860
                 Request::setTrustedProxies(array_merge(array($event->getRequest()->server->get('REMOTE_ADDR')), $config['trusted_proxies']));
861 861
             }, self::EARLY_EVENT);
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
         $this->register(new ServiceProvider\EccubePluginServiceProvider());
873 873
 
874 874
         // TODO Acme\ServiceProvider の初期化はここで OK?
875
-        if (array_key_exists('service',$this['config'])) {
875
+        if (array_key_exists('service', $this['config'])) {
876 876
             foreach ($this['config']['service'] as $service) {
877 877
                 $this->register(new $service);
878 878
             }
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
         $app = $this;
1029 1029
 
1030 1030
         // Response Event(http cache対応、event実行は一番遅く設定)
1031
-        $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function (\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) {
1031
+        $this->on(\Symfony\Component\HttpKernel\KernelEvents::RESPONSE, function(\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event) use ($app) {
1032 1032
 
1033 1033
             if (!$event->isMasterRequest()) {
1034 1034
                 return;
Please login to merge, or discard this patch.