Passed
Pull Request — master (#84)
by Yaroslav
05:15
created

PayoneDependencyProvider::addSalesFacade()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Payone;
9
10
use Spryker\Shared\Kernel\Store;
11
use Spryker\Zed\Kernel\AbstractBundleDependencyProvider;
12
use Spryker\Zed\Kernel\Container;
13
use SprykerEco\Zed\Payone\Dependency\Facade\PayoneToCalculationBridge;
14
use SprykerEco\Zed\Payone\Dependency\Facade\PayoneToGlossaryFacadeBridge;
15
use SprykerEco\Zed\Payone\Dependency\Facade\PayoneToOmsBridge;
16
use SprykerEco\Zed\Payone\Dependency\Facade\PayoneToRefundBridge;
17
use SprykerEco\Zed\Payone\Dependency\Facade\PayoneToSalesBridge;
18
use SprykerEco\Zed\Payone\Dependency\Facade\PayoneToStoreFacadeBridge;
19
20
class PayoneDependencyProvider extends AbstractBundleDependencyProvider
21
{
22
    /**
23
     * @var string
24
     */
25
    public const FACADE_OMS = 'oms facade';
26
    /**
27
     * @var string
28
     */
29
    public const FACADE_REFUND = 'refund facade';
30
31
    /**
32
     * @var string
33
     */
34
    public const FACADE_SALES = 'sales facade';
35
36
    /**
37
     * @var string
38
     */
39
    public const FACADE_GLOSSARY = 'glossary facade';
40
41
    /**
42
     * @var string
43
     */
44
    public const FACADE_CALCULATION = 'calculation facade';
45
46
    /**
47
     * @var string
48
     */
49
    public const FACADE_STORE = 'FACADE_STORE';
50
51
    /**
52
     * @uses \Spryker\Zed\Http\Communication\Plugin\Application\HttpApplicationPlugin::SERVICE_REQUEST_STACK
53
     */
54
    public const SERVICE_REQUEST_STACK = 'request_stack';
55
56
    /**
57
     * @param \Spryker\Zed\Kernel\Container $container
58
     *
59
     * @return \Spryker\Zed\Kernel\Container
60
     */
61
    public function provideCommunicationLayerDependencies(Container $container)
62
    {
63
        $container = parent::provideCommunicationLayerDependencies($container);
64
        $container = $this->addOmsFacade($container);
65
        $container = $this->addRefundFacade($container);
66
        $container = $this->addSalesFacade($container);
67
        $container = $this->addCalculationFacade($container);
68
69
        return $container;
70
    }
71
72
    /**
73
     * @param \Spryker\Zed\Kernel\Container $container
74
     *
75
     * @return \Spryker\Zed\Kernel\Container
76
     */
77
    public function provideBusinessLayerDependencies(Container $container)
78
    {
79
        $container = parent::provideBusinessLayerDependencies($container);
80
        $container = $this->addGlossaryFacade($container);
81
        $container = $this->addStore($container);
0 ignored issues
show
Bug introduced by
The method addStore() does not exist on SprykerEco\Zed\Payone\PayoneDependencyProvider. Did you maybe mean addStoreFacade()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

81
        /** @scrutinizer ignore-call */ 
82
        $container = $this->addStore($container);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
82
        $container = $this->addStoreFacade($container);
83
        $container = $this->addRequestStack($container);
84
85
        return $container;
86
    }
87
88
    /**
89
     * @param \Spryker\Zed\Kernel\Container $container
90
     *
91
     * @return \Spryker\Zed\Kernel\Container
92
     */
93
    protected function addOmsFacade(Container $container): Container
94
    {
95
        $container->set(static::FACADE_OMS, function (Container $container) {
96
            return new PayoneToOmsBridge($container->getLocator()->oms()->facade());
97
        });
98
99
        return $container;
100
    }
101
102
    /**
103
     * @param \Spryker\Zed\Kernel\Container $container
104
     *
105
     * @return \Spryker\Zed\Kernel\Container
106
     */
107
    protected function addRefundFacade(Container $container): Container
108
    {
109
        $container->set(static::FACADE_REFUND, function (Container $container) {
110
            return new PayoneToRefundBridge($container->getLocator()->refund()->facade());
111
        });
112
113
        return $container;
114
    }
115
116
    /**
117
     * @param \Spryker\Zed\Kernel\Container $container
118
     *
119
     * @return \Spryker\Zed\Kernel\Container
120
     */
121
    protected function addSalesFacade(Container $container): Container
122
    {
123
        $container->set(static::FACADE_SALES, function (Container $container) {
124
            return new PayoneToSalesBridge($container->getLocator()->sales()->facade());
125
        });
126
127
        return $container;
128
    }
129
130
    /**
131
     * @param \Spryker\Zed\Kernel\Container $container
132
     *
133
     * @return \Spryker\Zed\Kernel\Container
134
     */
135
    protected function addCalculationFacade(Container $container): Container
136
    {
137
        $container->set(static::FACADE_CALCULATION, function (Container $container) {
138
            return new PayoneToCalculationBridge($container->getLocator()->calculation()->facade());
139
        });
140
141
        return $container;
142
    }
143
144
    /**
145
     * @param \Spryker\Zed\Kernel\Container $container
146
     *
147
     * @return \Spryker\Zed\Kernel\Container
148
     */
149
    protected function addGlossaryFacade(Container $container): Container
150
    {
151
        $container->set(static::FACADE_GLOSSARY, function (Container $container) {
152
            return new PayoneToGlossaryFacadeBridge($container->getLocator()->glossary()->facade());
153
        });
154
155
        return $container;
156
    }
157
158
    /**
159
     * @param \Spryker\Zed\Kernel\Container $container
160
     *
161
     * @return \Spryker\Zed\Kernel\Container
162
     */
163
    protected function addStoreFacade(Container $container): Container
164
    {
165
        $container->set(static::FACADE_STORE, function (Container $container) {
166
            return new PayoneToStoreFacadeBridge($container->getLocator()->store()->facade());
167
        });
168
169
        return $container;
170
    }
171
172
    /**
173
     * @param \Spryker\Zed\Kernel\Container $container
174
     *
175
     * @return \Spryker\Zed\Kernel\Container
176
     */
177
    protected function addRequestStack(Container $container): Container
178
    {
179
        $container->set(static::SERVICE_REQUEST_STACK, function (Container $container) {
180
            return $container->getApplicationService(static::SERVICE_REQUEST_STACK);
181
        });
182
183
        return $container;
184
    }
185
}
186