8
8
namespace Magento \LoginAsCustomerFrontendUi \ViewModel ;
9
9
10
10
use Magento \Customer \Model \Context ;
11
+ use Magento \Framework \App \Http \Context as HttpContext ;
11
12
use Magento \LoginAsCustomerApi \Api \ConfigInterface ;
13
+ use Magento \LoginAsCustomerApi \Api \GetLoggedAsCustomerAdminIdInterface ;
12
14
13
15
/**
14
16
* View model to get extension configuration in the template
@@ -21,20 +23,28 @@ class Configuration implements \Magento\Framework\View\Element\Block\ArgumentInt
21
23
private $ config ;
22
24
23
25
/**
24
- * @var \Magento\Framework\App\Http\Context
26
+ * @var HttpContext
25
27
*/
26
28
private $ httpContext ;
27
29
30
+ /**
31
+ * @var GetLoggedAsCustomerAdminIdInterface
32
+ */
33
+ private $ getLoggedAsCustomerAdminId ;
34
+
28
35
/**
29
36
* @param ConfigInterface $config
30
- * @param \Magento\Framework\App\Http\Context $httpContext
37
+ * @param HttpContext $httpContext
38
+ * @param GetLoggedAsCustomerAdminIdInterface $getLoggedAsCustomerAdminId
31
39
*/
32
40
public function __construct (
33
41
ConfigInterface $ config ,
34
- \Magento \Framework \App \Http \Context $ httpContext
42
+ HttpContext $ httpContext ,
43
+ GetLoggedAsCustomerAdminIdInterface $ getLoggedAsCustomerAdminId
35
44
) {
36
45
$ this ->config = $ config ;
37
46
$ this ->httpContext = $ httpContext ;
47
+ $ this ->getLoggedAsCustomerAdminId = $ getLoggedAsCustomerAdminId ;
38
48
}
39
49
40
50
/**
@@ -44,7 +54,7 @@ public function __construct(
44
54
*/
45
55
public function isEnabled (): bool
46
56
{
47
- return $ this ->config ->isEnabled () && $ this ->isLoggedIn ();
57
+ return $ this ->config ->isEnabled () && $ this ->isLoggedIn () && $ this -> getLoggedAsCustomerAdminId -> execute () ;
48
58
}
49
59
50
60
/**
0 commit comments