Skip to content

Commit 75ac691

Browse files
magento/magento2-login-as-customer#144: Banner is not shown on Category page if Disable Page Cache For Admin User = No - updated.
1 parent 07f03fe commit 75ac691

File tree

9 files changed

+14
-16
lines changed

9 files changed

+14
-16
lines changed

app/code/Magento/LoginAsCustomer/Model/AuthenticateCustomerBySecret.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\LoginAsCustomer\Model;
99

1010
use Magento\Customer\Model\Session;
11+
use Magento\Framework\App\ObjectManager;
1112
use Magento\Framework\Exception\LocalizedException;
1213
use Magento\LoginAsCustomerApi\Api\AuthenticateCustomerBySecretInterface;
1314
use Magento\LoginAsCustomerApi\Api\GetAuthenticationDataBySecretInterface;
@@ -43,11 +44,11 @@ class AuthenticateCustomerBySecret implements AuthenticateCustomerBySecretInterf
4344
public function __construct(
4445
GetAuthenticationDataBySecretInterface $getAuthenticationDataBySecret,
4546
Session $customerSession,
46-
SetLoggedAsCustomerAdminIdInterface $setLoggedAsCustomerAdminId
47+
?SetLoggedAsCustomerAdminIdInterface $setLoggedAsCustomerAdminId = null
4748
) {
4849
$this->getAuthenticationDataBySecret = $getAuthenticationDataBySecret;
4950
$this->customerSession = $customerSession;
50-
$this->setLoggedAsCustomerAdminId = $setLoggedAsCustomerAdminId;
51+
$this->setLoggedAsCustomerAdminId = $setLoggedAsCustomerAdminId ?? ObjectManager::getInstance()->get(SetLoggedAsCustomerAdminIdInterface::class);
5152
}
5253

5354
/**

app/code/Magento/LoginAsCustomerAdminUi/Controller/Adminhtml/Login/Login.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Backend\Model\Auth\Session;
1313
use Magento\Customer\Api\CustomerRepositoryInterface;
1414
use Magento\Framework\App\Action\HttpGetActionInterface;
15+
use Magento\Framework\App\ObjectManager;
1516
use Magento\Framework\Controller\Result\Redirect;
1617
use Magento\Framework\Controller\ResultFactory;
1718
use Magento\Framework\Controller\ResultInterface;
@@ -110,7 +111,7 @@ public function __construct(
110111
SaveAuthenticationDataInterface $saveAuthenticationData,
111112
DeleteAuthenticationDataForUserInterface $deleteAuthenticationDataForUser,
112113
Url $url,
113-
SetLoggedAsCustomerCustomerIdInterface $setLoggedAsCustomerCustomerId
114+
?SetLoggedAsCustomerCustomerIdInterface $setLoggedAsCustomerCustomerId = null
114115
) {
115116
parent::__construct($context);
116117

@@ -122,7 +123,7 @@ public function __construct(
122123
$this->saveAuthenticationData = $saveAuthenticationData;
123124
$this->deleteAuthenticationDataForUser = $deleteAuthenticationDataForUser;
124125
$this->url = $url;
125-
$this->setLoggedAsCustomerCustomerId = $setLoggedAsCustomerCustomerId;
126+
$this->setLoggedAsCustomerCustomerId = $setLoggedAsCustomerCustomerId ?? ObjectManager::getInstance()->get(SetLoggedAsCustomerCustomerIdInterface::class);
126127
}
127128

128129
/**

app/code/Magento/LoginAsCustomerApi/Api/GetLoggedAsCustomerAdminIdInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
/**
1111
* Get id of Admin logged as Customer.
12-
*
13-
* @api
1412
*/
1513
interface GetLoggedAsCustomerAdminIdInterface
1614
{

app/code/Magento/LoginAsCustomerApi/Api/GetLoggedAsCustomerCustomerIdInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
/**
1111
* Get id of Customer Admin is logged as.
12-
*
13-
* @api
1412
*/
1513
interface GetLoggedAsCustomerCustomerIdInterface
1614
{

app/code/Magento/LoginAsCustomerApi/Api/SetLoggedAsCustomerAdminIdInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
/**
1111
* Set id of Admin logged as Customer.
12-
*
13-
* @api
1412
*/
1513
interface SetLoggedAsCustomerAdminIdInterface
1614
{

app/code/Magento/LoginAsCustomerApi/Api/SetLoggedAsCustomerCustomerIdInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
/**
1111
* Set id of Customer Admin is logged as.
12-
*
13-
* @api
1412
*/
1513
interface SetLoggedAsCustomerCustomerIdInterface
1614
{

app/code/Magento/LoginAsCustomerFrontendUi/CustomerData/LoginAsCustomerUi.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Customer\CustomerData\SectionSourceInterface;
1111
use Magento\Customer\Model\Session;
12+
use Magento\Framework\App\ObjectManager;
1213
use Magento\Framework\Exception\LocalizedException;
1314
use Magento\LoginAsCustomerApi\Api\GetLoggedAsCustomerAdminIdInterface;
1415
use Magento\Store\Model\StoreManagerInterface;
@@ -43,11 +44,11 @@ class LoginAsCustomerUi implements SectionSourceInterface
4344
public function __construct(
4445
Session $customerSession,
4546
StoreManagerInterface $storeManager,
46-
GetLoggedAsCustomerAdminIdInterface $getLoggedAsCustomerAdminId
47+
?GetLoggedAsCustomerAdminIdInterface $getLoggedAsCustomerAdminId = null
4748
) {
4849
$this->customerSession = $customerSession;
4950
$this->storeManager = $storeManager;
50-
$this->getLoggedAsCustomerAdminId = $getLoggedAsCustomerAdminId;
51+
$this->getLoggedAsCustomerAdminId = $getLoggedAsCustomerAdminId ?? ObjectManager::getInstance()->get(GetLoggedAsCustomerAdminIdInterface::class);
5152
}
5253

5354
/**

app/code/Magento/LoginAsCustomerFrontendUi/Plugin/KeepLoginAsCustomerSessionDataPlugin.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\LoginAsCustomerFrontendUi\Plugin;
810

911
use Magento\Framework\Session\SessionManagerInterface;

app/code/Magento/LoginAsCustomerFrontendUi/ViewModel/Configuration.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Customer\Model\Context;
1111
use Magento\Framework\App\Http\Context as HttpContext;
12+
use Magento\Framework\App\ObjectManager;
1213
use Magento\LoginAsCustomerApi\Api\ConfigInterface;
1314
use Magento\LoginAsCustomerApi\Api\GetLoggedAsCustomerAdminIdInterface;
1415

@@ -40,11 +41,11 @@ class Configuration implements \Magento\Framework\View\Element\Block\ArgumentInt
4041
public function __construct(
4142
ConfigInterface $config,
4243
HttpContext $httpContext,
43-
GetLoggedAsCustomerAdminIdInterface $getLoggedAsCustomerAdminId
44+
?GetLoggedAsCustomerAdminIdInterface $getLoggedAsCustomerAdminId = null
4445
) {
4546
$this->config = $config;
4647
$this->httpContext = $httpContext;
47-
$this->getLoggedAsCustomerAdminId = $getLoggedAsCustomerAdminId;
48+
$this->getLoggedAsCustomerAdminId = $getLoggedAsCustomerAdminId ?? ObjectManager::getInstance()->get(GetLoggedAsCustomerAdminIdInterface::class);
4849
}
4950

5051
/**

0 commit comments

Comments
 (0)