Skip to content

Commit ac4aa67

Browse files
committed
magento2-login-as-customer/issues/104: Global refactoring
- LoginAsCustomerSales refactoring
1 parent bf65ffc commit ac4aa67

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

app/code/Magento/LoginAsCustomerSales/Plugin/AuthenticateCustomer.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Magento\LoginAsCustomerSales\Plugin;
@@ -34,7 +33,6 @@ class AuthenticateCustomer
3433
private $quoteRepository;
3534

3635
/**
37-
* AuthenticateCustomer constructor.
3836
* @param CustomerSession $customerSession
3937
* @param CheckoutSession $checkoutSession
4038
* @param CartRepositoryInterface $quoteRepository
@@ -51,9 +49,14 @@ public function __construct(
5149

5250
/**
5351
* Remove all items from guest shopping cart
52+
*
5453
* @param AuthenticateCustomerInterface $subject
5554
* @param int $customerId
5655
* @param int $adminId
56+
* @throws \Magento\Framework\Exception\LocalizedException
57+
* @throws \Magento\Framework\Exception\NoSuchEntityException
58+
*
59+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5760
*/
5861
public function beforeExecute(
5962
AuthenticateCustomerInterface $subject,
@@ -71,14 +74,17 @@ public function beforeExecute(
7174
}
7275

7376
/**
74-
* Mart customer cart as not guest
75-
* @return bool
76-
* @throws \Magento\Framework\Exception\LocalizedException
77-
* @throws \Magento\Framework\Exception\NoSuchEntityException
77+
* Mark customer cart as not guest
78+
*
7879
* @param int $adminId
7980
* @param AuthenticateCustomerInterface $subject
8081
* @param bool $result
8182
* @param int $customerId
83+
* @return bool
84+
* @throws \Magento\Framework\Exception\LocalizedException
85+
* @throws \Magento\Framework\Exception\NoSuchEntityException
86+
*
87+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
8288
*/
8389
public function afterExecute(
8490
AuthenticateCustomerInterface $subject,
@@ -87,7 +93,6 @@ public function afterExecute(
8793
int $adminId
8894
) {
8995
if ($result) {
90-
/* Load Customer Quote */
9196
$this->checkoutSession->loadCustomerQuote();
9297

9398
$quote = $this->checkoutSession->getQuote();

app/code/Magento/LoginAsCustomerSales/composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"AFL-3.0"
1515
],
1616
"autoload": {
17-
"files": [ "registration.php" ],
17+
"files": [
18+
"registration.php"
19+
],
1820
"psr-4": {
1921
"Magento\\LoginAsCustomerSales\\": ""
2022
}

app/code/Magento/LoginAsCustomerSales/etc/di.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9-
<type name="Magento\LoginAsCustomer\Api\AuthenticateCustomerInterface">
10-
<plugin disabled="false" name="login_as_customer_sales_authenticate_customer" sortOrder="10" type="Magento\LoginAsCustomerSales\Plugin\AuthenticateCustomer"/>
11-
</type>
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
10+
<type name="Magento\LoginAsCustomer\Api\AuthenticateCustomerInterface">
11+
<plugin name="login_as_customer_sales_authenticate_customer"
12+
type="Magento\LoginAsCustomerSales\Plugin\AuthenticateCustomer"/>
13+
</type>
1214
</config>

app/code/Magento/LoginAsCustomerSales/etc/module.xml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_LoginAsCustomerSales" setup_version="2.2.1">
10-
<sequence>
11-
<module name="Magento_LoginAsCustomer"/>
12-
<module name="Magento_Customer"/>
13-
<module name="Magento_Checkout"/>
14-
<module name="Magento_Quote"/>
15-
</sequence>
16-
</module>
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
10+
<module name="Magento_LoginAsCustomerSales"/>
1711
</config>

0 commit comments

Comments
 (0)