1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2014 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
declare (strict_types=1 );
7
7
12
12
use Magento \Framework \App \ObjectManager ;
13
13
use Magento \LoginAsCustomerApi \Api \ConfigInterface ;
14
14
use Magento \LoginAsCustomerApi \Api \GetLoggedAsCustomerAdminIdInterface ;
15
+ use Magento \Framework \App \Config \ScopeConfigInterface ;
16
+ use Magento \Store \Model \StoreManagerInterface ;
15
17
16
18
/**
17
19
* View model to get extension configuration in the template
@@ -33,20 +35,36 @@ class Configuration implements \Magento\Framework\View\Element\Block\ArgumentInt
33
35
*/
34
36
private $ getLoggedAsCustomerAdminId ;
35
37
38
+ /**
39
+ * @var ScopeConfigInterface
40
+ */
41
+ private $ scopeConfig ;
42
+
43
+ /**
44
+ * @var StoreManagerInterface
45
+ */
46
+ private $ storeManager ;
47
+
36
48
/**
37
49
* @param ConfigInterface $config
38
50
* @param HttpContext $httpContext
51
+ * @param ScopeConfigInterface $scopeConfig
52
+ * @param StoreManagerInterface $storeManager
39
53
* @param GetLoggedAsCustomerAdminIdInterface $getLoggedAsCustomerAdminId
40
54
*/
41
55
public function __construct (
42
56
ConfigInterface $ config ,
43
57
HttpContext $ httpContext ,
58
+ ScopeConfigInterface $ scopeConfig ,
59
+ StoreManagerInterface $ storeManager ,
44
60
?GetLoggedAsCustomerAdminIdInterface $ getLoggedAsCustomerAdminId = null
45
61
) {
46
62
$ this ->config = $ config ;
47
63
$ this ->httpContext = $ httpContext ;
48
64
$ this ->getLoggedAsCustomerAdminId = $ getLoggedAsCustomerAdminId
49
65
?? ObjectManager::getInstance ()->get (GetLoggedAsCustomerAdminIdInterface::class);
66
+ $ this ->scopeConfig = $ scopeConfig ;
67
+ $ this ->storeManager = $ storeManager ;
50
68
}
51
69
52
70
/**
@@ -68,4 +86,19 @@ private function isLoggedIn(): bool
68
86
{
69
87
return (bool )$ this ->httpContext ->getValue (Context::CONTEXT_AUTH );
70
88
}
89
+
90
+ /**
91
+ * Is B2b enabled
92
+ *
93
+ * @return bool
94
+ * @throws \Magento\Framework\Exception\NoSuchEntityException
95
+ */
96
+ public function isB2bEnabled (): bool
97
+ {
98
+ return (bool )$ this ->scopeConfig ->getValue (
99
+ "btob/website_configuration/company_active " ,
100
+ \Magento \Store \Model \ScopeInterface::SCOPE_WEBSITE ,
101
+ $ this ->storeManager ->getStore ()->getWebsiteId ()
102
+ );
103
+ }
71
104
}
0 commit comments