Passed
Pull Request — master (#84)
by
unknown
10:12
created

provideCommunicationLayerDependencies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 9
rs 10
c 1
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
    public const FACADE_OMS = 'oms facade';
23
    public const FACADE_REFUND = 'refund facade';
24
    /**
25
     * @deprecated Will be removed without replacement
26
     */
27
    public const STORE_CONFIG = 'store config';
28
    public const FACADE_SALES = 'sales facade';
29
    public const FACADE_GLOSSARY = 'glossary facade';
30
    public const FACADE_CALCULATION = 'calculation facade';
31
    public const FACADE_STORE = 'FACADE_STORE';
32
33
    /**
34
     * @uses \Spryker\Zed\Http\Communication\Plugin\Application\HttpApplicationPlugin::SERVICE_REQUEST_STACK
35
     */
36
    public const SERVICE_REQUEST_STACK = 'request_stack';
37
38
    /**
39
     * @param \Spryker\Zed\Kernel\Container $container
40
     *
41
     * @return \Spryker\Zed\Kernel\Container
42
     */
43
    public function provideCommunicationLayerDependencies(Container $container)
44
    {
45
        $container = parent::provideCommunicationLayerDependencies($container);
46
        $container = $this->addOmsFacade($container);
47
        $container = $this->addRefundFacade($container);
48
        $container = $this->addSalesFacade($container);
49
        $container = $this->addCalculationFacade($container);
50
51
        return $container;
52
    }
53
54
    /**
55
     * @param \Spryker\Zed\Kernel\Container $container
56
     *
57
     * @return \Spryker\Zed\Kernel\Container
58
     */
59
    public function provideBusinessLayerDependencies(Container $container)
60
    {
61
        $container = parent::provideBusinessLayerDependencies($container);
62
        $container = $this->addGlossaryFacade($container);
63
        $container = $this->addStore($container);
0 ignored issues
show
Deprecated Code introduced by
The function SprykerEco\Zed\Payone\Pa...ncyProvider::addStore() has been deprecated: Will be removed without replacement ( Ignorable by Annotation )

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

63
        $container = /** @scrutinizer ignore-deprecated */ $this->addStore($container);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
64
        $container = $this->addStoreFacade($container);
65
        $container = $this->addRequestStack($container);
66
67
        return $container;
68
    }
69
70
    /**
71
     * @param \Spryker\Zed\Kernel\Container $container
72
     *
73
     * @return \Spryker\Zed\Kernel\Container
74
     */
75
    protected function addOmsFacade(Container $container): Container
76
    {
77
        $container->set(static::FACADE_OMS, function (Container $container) {
78
            return new PayoneToOmsBridge($container->getLocator()->oms()->facade());
79
        });
80
81
        return $container;
82
    }
83
84
    /**
85
     * @param \Spryker\Zed\Kernel\Container $container
86
     *
87
     * @return \Spryker\Zed\Kernel\Container
88
     */
89
    protected function addRefundFacade(Container $container): Container
90
    {
91
        $container->set(static::FACADE_REFUND, function (Container $container) {
92
            return new PayoneToRefundBridge($container->getLocator()->refund()->facade());
93
        });
94
95
        return $container;
96
    }
97
98
    /**
99
     * @param \Spryker\Zed\Kernel\Container $container
100
     *
101
     * @return \Spryker\Zed\Kernel\Container
102
     */
103
    protected function addSalesFacade(Container $container): Container
104
    {
105
        $container->set(static::FACADE_SALES, function (Container $container) {
106
            return new PayoneToSalesBridge($container->getLocator()->sales()->facade());
107
        });
108
109
        return $container;
110
    }
111
112
    /**
113
     * @param \Spryker\Zed\Kernel\Container $container
114
     *
115
     * @return \Spryker\Zed\Kernel\Container
116
     */
117
    protected function addCalculationFacade(Container $container): Container
118
    {
119
        $container->set(static::FACADE_CALCULATION, function (Container $container) {
120
            return new PayoneToCalculationBridge($container->getLocator()->calculation()->facade());
121
        });
122
123
        return $container;
124
    }
125
126
    /**
127
     * @param \Spryker\Zed\Kernel\Container $container
128
     *
129
     * @return \Spryker\Zed\Kernel\Container
130
     */
131
    protected function addGlossaryFacade(Container $container): Container
132
    {
133
        $container->set(static::FACADE_GLOSSARY, function (Container $container) {
134
            return new PayoneToGlossaryFacadeBridge($container->getLocator()->glossary()->facade());
135
        });
136
137
        return $container;
138
    }
139
140
    /**
141
     * @deprecated Will be removed without replacement
142
     *
143
     * @param \Spryker\Zed\Kernel\Container $container
144
     *
145
     * @return \Spryker\Zed\Kernel\Container
146
     */
147
    protected function addStore(Container $container): Container
148
    {
149
        $container->set(static::STORE_CONFIG, function () {
0 ignored issues
show
Deprecated Code introduced by
The constant SprykerEco\Zed\Payone\Pa...yProvider::STORE_CONFIG has been deprecated: Will be removed without replacement ( Ignorable by Annotation )

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

149
        $container->set(/** @scrutinizer ignore-deprecated */ static::STORE_CONFIG, function () {

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
150
            return Store::getInstance();
151
        });
152
153
        return $container;
154
    }
155
156
    /**
157
     * @param \Spryker\Zed\Kernel\Container $container
158
     *
159
     * @return \Spryker\Zed\Kernel\Container
160
     */
161
    protected function addStoreFacade(Container $container): Container
162
    {
163
        $container->set(static::FACADE_STORE, function (Container $container) {
164
            return new PayoneToStoreFacadeBridge($container->getLocator()->store()->facade());
165
        });
166
167
        return $container;
168
    }
169
170
    /**
171
     * @param \Spryker\Zed\Kernel\Container $container
172
     *
173
     * @return \Spryker\Zed\Kernel\Container
174
     */
175
    protected function addRequestStack(Container $container): Container
176
    {
177
        $container->set(static::SERVICE_REQUEST_STACK, function (Container $container) {
178
            return $container->getApplicationService(static::SERVICE_REQUEST_STACK);
179
        });
180
181
        return $container;
182
    }
183
}
184