Completed
Push — master ( 95f92c...954431 )
by
unknown
17s queued 12s
created

getPreAddToCartPlugins()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerShop\Yves\CartPage;
9
10
use Spryker\Yves\Kernel\AbstractBundleDependencyProvider;
11
use Spryker\Yves\Kernel\Container;
12
use Spryker\Yves\Kernel\Plugin\Pimple;
13
use SprykerShop\Yves\CartPage\Dependency\Client\CartPageToAvailabilityStorageClientBridge;
14
use SprykerShop\Yves\CartPage\Dependency\Client\CartPageToCartClientBridge;
15
use SprykerShop\Yves\CartPage\Dependency\Client\CartPageToProductStorageClientBridge;
16
use SprykerShop\Yves\CartPage\Dependency\Client\CartPageToQuoteClientBridge;
17
use SprykerShop\Yves\CartPage\Dependency\Client\CartPageToZedRequestClientBridge;
18
use SprykerShop\Yves\CartPage\Plugin\CartVariantAttributeMapperPlugin;
19
20
class CartPageDependencyProvider extends AbstractBundleDependencyProvider
21
{
22
    public const CLIENT_CART = 'CLIENT_CART';
23
    public const CLIENT_QUOTE = 'CLIENT_QUOTE';
24
    public const CLIENT_PRODUCT_STORAGE = 'CLIENT_PRODUCT_STORAGE';
25
    public const CLIENT_AVAILABILITY_STORAGE = 'CLIENT_AVAILABILITY_STORAGE';
26
    public const PLUGIN_APPLICATION = 'PLUGIN_APPLICATION';
27
    public const PLUGIN_CART_VARIANT = 'PLUGIN_CART_VARIANT';
28
    public const PLUGIN_CART_ITEM_TRANSFORMERS = 'PLUGIN_CART_ITEM_TRANSFORMERS';
29
    public const PLUGIN_CART_PAGE_WIDGETS = 'PLUGIN_CART_PAGE_WIDGETS';
30
    public const PLUGIN_PRE_ADD_TO_CART = 'PLUGIN_PRE_ADD_TO_CART';
31
    public const CLIENT_ZED_REQUEST = 'CLIENT_ZED_REQUEST';
32
33
    /**
34
     * @param \Spryker\Yves\Kernel\Container $container
35
     *
36
     * @return \Spryker\Yves\Kernel\Container
37
     */
38
    public function provideDependencies(Container $container)
39
    {
40
        $container = $this->addCartClient($container);
41
        $container = $this->addQuoteClient($container);
42
        $container = $this->addProductStorageClient($container);
43
        $container = $this->addAvailabilityStorageClient($container);
44
        $container = $this->addApplication($container);
45
        $container = $this->addCartVariantAttributeMapperPlugin($container);
46
        $container = $this->addCartPageWidgetPlugins($container);
47
        $container = $this->addCartItemTransformerPlugins($container);
48
        $container = $this->addPreAddToCartPlugins($container);
49
        $container = $this->addZedRequestClient($container);
50
51
        return $container;
52
    }
53
54
    /**
55
     * @param \Spryker\Yves\Kernel\Container $container
56
     *
57
     * @return \Spryker\Yves\Kernel\Container
58
     */
59
    protected function addCartClient(Container $container): Container
60
    {
61
        $container[self::CLIENT_CART] = function (Container $container) {
62
            return new CartPageToCartClientBridge($container->getLocator()->cart()->client());
63
        };
64
65
        return $container;
66
    }
67
68
    /**
69
     * @param \Spryker\Yves\Kernel\Container $container
70
     *
71
     * @return \Spryker\Yves\Kernel\Container
72
     */
73
    protected function addQuoteClient(Container $container): Container
74
    {
75
        $container[static::CLIENT_QUOTE] = function (Container $container) {
76
            return new CartPageToQuoteClientBridge($container->getLocator()->quote()->client());
77
        };
78
79
        return $container;
80
    }
81
82
    /**
83
     * @param \Spryker\Yves\Kernel\Container $container
84
     *
85
     * @return \Spryker\Yves\Kernel\Container
86
     */
87
    protected function addProductStorageClient(Container $container): Container
88
    {
89
        $container[static::CLIENT_PRODUCT_STORAGE] = function (Container $container) {
90
            return new CartPageToProductStorageClientBridge($container->getLocator()->productStorage()->client());
91
        };
92
93
        return $container;
94
    }
95
96
    /**
97
     * @param \Spryker\Yves\Kernel\Container $container
98
     *
99
     * @return \Spryker\Yves\Kernel\Container
100
     */
101
    protected function addAvailabilityStorageClient(Container $container): Container
102
    {
103
        $container[static::CLIENT_AVAILABILITY_STORAGE] = function (Container $container) {
104
            return new CartPageToAvailabilityStorageClientBridge($container->getLocator()->availabilityStorage()->client());
105
        };
106
107
        return $container;
108
    }
109
110
    /**
111
     * @param \Spryker\Yves\Kernel\Container $container
112
     *
113
     * @return \Spryker\Yves\Kernel\Container
114
     */
115
    protected function addZedRequestClient(Container $container): Container
116
    {
117
        $container[self::CLIENT_ZED_REQUEST] = function (Container $container) {
118
            return new CartPageToZedRequestClientBridge($container->getLocator()->zedRequest()->client());
119
        };
120
121
        return $container;
122
    }
123
124
    /**
125
     * @param \Spryker\Yves\Kernel\Container $container
126
     *
127
     * @return \Spryker\Yves\Kernel\Container
128
     */
129
    protected function addApplication(Container $container): Container
130
    {
131
        $container[self::PLUGIN_APPLICATION] = function () {
132
            $pimplePlugin = new Pimple();
133
134
            return $pimplePlugin->getApplication();
135
        };
136
137
        return $container;
138
    }
139
140
    /**
141
     * @param \Spryker\Yves\Kernel\Container $container
142
     *
143
     * @return \Spryker\Yves\Kernel\Container
144
     */
145
    protected function addCartVariantAttributeMapperPlugin(Container $container): Container
146
    {
147
        $container[self::PLUGIN_CART_VARIANT] = function () {
148
            return new CartVariantAttributeMapperPlugin();
149
        };
150
151
        return $container;
152
    }
153
154
    /**
155
     * @param \Spryker\Yves\Kernel\Container $container
156
     *
157
     * @return \Spryker\Yves\Kernel\Container
158
     */
159
    protected function addCartPageWidgetPlugins(Container $container)
160
    {
161
        $container[self::PLUGIN_CART_PAGE_WIDGETS] = function () {
162
            return $this->getCartPageWidgetPlugins();
163
        };
164
165
        return $container;
166
    }
167
168
    /**
169
     * Returns a list of widget plugin class names that implement
170
     * Spryker\Yves\Kernel\Dependency\Plugin\WidgetPluginInterface.
171
     *
172
     * @return string[]
173
     */
174
    protected function getCartPageWidgetPlugins(): array
175
    {
176
        return [];
177
    }
178
179
    /**
180
     * @param \Spryker\Yves\Kernel\Container $container
181
     *
182
     * @return \Spryker\Yves\Kernel\Container
183
     */
184
    protected function addCartItemTransformerPlugins(Container $container)
185
    {
186
        $container[static::PLUGIN_CART_ITEM_TRANSFORMERS] = function () {
187
            return $this->getCartItemTransformerPlugins();
188
        };
189
190
        return $container;
191
    }
192
193
    /**
194
     * @return \SprykerShop\Yves\CartPage\Dependency\Plugin\CartItemTransformerPluginInterface[]
195
     */
196
    protected function getCartItemTransformerPlugins(): array
197
    {
198
        return [];
199
    }
200
201
    /**
202
     * @param \Spryker\Yves\Kernel\Container $container
203
     *
204
     * @return \Spryker\Yves\Kernel\Container
205
     */
206
    protected function addPreAddToCartPlugins(Container $container): Container
207
    {
208
        $container->set(static::PLUGIN_PRE_ADD_TO_CART, function () {
209
            return $this->getPreAddToCartPlugins();
210
        });
211
212
        return $container;
213
    }
214
215
    /**
216
     * @return \SprykerShop\Yves\CartPageExtension\Dependency\Plugin\PreAddToCartPluginInterface[]
217
     */
218
    protected function getPreAddToCartPlugins(): array
219
    {
220
        return [];
221
    }
222
}
223