Completed
Push — experimental/3.1 ( 24445a...d4772e )
by Yangsin
271:33 queued 265:16
created

EccubeServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 66.67%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 36
ccs 2
cts 3
cp 0.6667
rs 10
c 2
b 0
f 0
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 18 1
A subscribe() 0 6 1
1
<?php
2
/*
3
 * This file is part of EC-CUBE
4
 *
5
 * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved.
6
 *
7
 * http://www.lockon.co.jp/
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
 */
23
24
25
namespace Eccube\ServiceProvider;
26
27
use Eccube\Doctrine\EventSubscriber\TaxRuleEventSubscriber;
28
use Eccube\Entity\BaseInfo;
29
use Eccube\Repository\BaseInfoRepository;
30
use Eccube\Service\TaxRuleService;
31
use Pimple\Container;
32
use Pimple\ServiceProviderInterface;
33
use Silex\Api\EventListenerProviderInterface;
34
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
35
use Symfony\Component\HttpFoundation\ParameterBag;
36
37
class EccubeServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
38
{
39
    /**
40
     * Registers services on the given app.
41
     *
42
     * This method should only be used to configure services and parameters.
43
     * It should not get services.
44
     *
45
     * @param BaseApplication $app An Application instance
46
     */
47
    public function register(Container $app)
48
    {
49
        $app[BaseInfo::class] = function () use ($app) {
50
            return $app[BaseInfoRepository::class]->get();
51
        };
52
53
        $app['request_scope'] = function () {
54
            return new ParameterBag();
55
        };
56
57
        // Application::initRenderingと一緒に修正
58
        $app['eccube.twig.block.templates'] = function () {
59
            $templates = new ArrayCollection();
60
            $templates[] = 'render_block.twig';
61
62
            return $templates;
63
        };
64 1069
    }
65
66
    public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
67 356
    {
68
        // Add event subscriber to TaxRuleEvent
69
        // initDoctrineのタイミングでは、TaxRuleServiceが定義されていないため, ここで追加.
70
        $app['orm.em']->getEventManager()->addEventSubscriber(new TaxRuleEventSubscriber($app[TaxRuleService::class]));
71
    }
72
}
73