Completed
Push — master ( c8e10c...47e8bc )
by
unknown
21s queued 16s
created

addQuoteClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Spryker Marketplace License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerShop\Yves\MerchantSwitcherWidget;
9
10
use Spryker\Yves\Kernel\AbstractBundleDependencyProvider;
11
use Spryker\Yves\Kernel\Container;
12
use Spryker\Yves\Kernel\Plugin\Pimple;
13
use SprykerShop\Yves\MerchantSwitcherWidget\Dependency\Client\MerchantSwitcherWidgetToMerchantSearchClientBridge;
14
use SprykerShop\Yves\MerchantSwitcherWidget\Dependency\Client\MerchantSwitcherWidgetToMerchantSwitcherClientBridge;
15
use SprykerShop\Yves\MerchantSwitcherWidget\Dependency\Client\MerchantSwitcherWidgetToQuoteClientBridge;
16
17
class MerchantSwitcherWidgetDependencyProvider extends AbstractBundleDependencyProvider
18
{
19
    public const CLIENT_MERCHANT_SEARCH = 'CLIENT_MERCHANT_SEARCH';
20
    public const PLUGIN_APPLICATION = 'PLUGIN_APPLICATION';
21
    public const CLIENT_QUOTE = 'CLIENT_QUOTE';
22
    public const CLIENT_MERCHANT_SWITCHER = 'CLIENT_MERCHANT_SWITCHER';
23
24
    /**
25
     * @param \Spryker\Yves\Kernel\Container $container
26
     *
27
     * @return \Spryker\Yves\Kernel\Container
28
     */
29
    public function provideDependencies(Container $container): Container
30
    {
31
        $container = parent::provideDependencies($container);
32
33
        $container = $this->addMerchantSearchClient($container);
34
        $container = $this->addApplication($container);
35
        $container = $this->addQuoteClient($container);
36
        $container = $this->addMerchantSwitcherClient($container);
37
38
        return $container;
39
    }
40
41
    /**
42
     * @param \Spryker\Yves\Kernel\Container $container
43
     *
44
     * @return \Spryker\Yves\Kernel\Container
45
     */
46
    protected function addMerchantSearchClient(Container $container): Container
47
    {
48
        $container->set(static::CLIENT_MERCHANT_SEARCH, function (Container $container) {
49
            return new MerchantSwitcherWidgetToMerchantSearchClientBridge($container->getLocator()->merchantSearch()->client());
50
        });
51
52
        return $container;
53
    }
54
55
    /**
56
     * @param \Spryker\Yves\Kernel\Container $container
57
     *
58
     * @return \Spryker\Yves\Kernel\Container
59
     */
60
    protected function addApplication(Container $container): Container
61
    {
62
        $container->set(static::PLUGIN_APPLICATION, function () {
63
            $pimplePlugin = new Pimple();
64
65
            return $pimplePlugin->getApplication();
66
        });
67
68
        return $container;
69
    }
70
71
    /**
72
     * @param \Spryker\Yves\Kernel\Container $container
73
     *
74
     * @return \Spryker\Yves\Kernel\Container
75
     */
76
    protected function addQuoteClient(Container $container): Container
77
    {
78
        $container->set(static::CLIENT_QUOTE, function (Container $container) {
79
            return new MerchantSwitcherWidgetToQuoteClientBridge($container->getLocator()->quote()->client());
80
        });
81
82
        return $container;
83
    }
84
85
    /**
86
     * @param \Spryker\Yves\Kernel\Container $container
87
     *
88
     * @return \Spryker\Yves\Kernel\Container
89
     */
90
    protected function addMerchantSwitcherClient(Container $container): Container
91
    {
92
        $container->set(static::CLIENT_MERCHANT_SWITCHER, function (Container $container) {
93
            return new MerchantSwitcherWidgetToMerchantSwitcherClientBridge($container->getLocator()->merchantSwitcher()->client());
94
        });
95
96
        return $container;
97
    }
98
}
99