Skip to content

Commit c3b95fd

Browse files
[Magento Community Engineering] Community Contributions - 2.4-develop
- merged latest code from mainline branch
2 parents 1e3bef5 + 468128c commit c3b95fd

27 files changed

+313
-315
lines changed

app/bootstrap.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
#ini_set('display_errors', 1);
1515

1616
/* PHP version validation */
17-
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 70103) {
17+
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 70300) {
1818
if (PHP_SAPI == 'cli') {
19-
echo 'Magento supports PHP 7.1.3 or later. ' .
20-
'Please read https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements-tech.html';
19+
echo 'Magento supports PHP 7.3.0 or later. ' .
20+
'Please read https://devdocs.magento.com/guides/v2.4/install-gde/system-requirements-tech.html';
2121
} else {
2222
echo <<<HTML
2323
<div style="font:12px/1.35em arial, helvetica, sans-serif;">
24-
<p>Magento supports PHP 7.1.3 or later. Please read
25-
<a target="_blank" href="https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements-tech.html">
24+
<p>Magento supports PHP 7.3.0 or later. Please read
25+
<a target="_blank" href="https://devdocs.magento.com/guides/v2.4/install-gde/system-requirements-tech.html">
2626
Magento System Requirements</a>.
2727
</div>
2828
HTML;

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

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@
1010
use Magento\Framework\App\Config\ScopeConfigInterface;
1111
use Magento\LoginAsCustomerApi\Api\ConfigInterface;
1212

13-
/**
14-
* @inheritdoc
15-
*/
1613
class Config implements ConfigInterface
1714
{
18-
/**
19-
* Extension config path
20-
*/
21-
private const XML_PATH_ENABLED
22-
= 'login_as_customer/general/enabled';
15+
private const XML_PATH_ENABLED = 'login_as_customer/general/enabled';
2316
private const XML_PATH_STORE_VIEW_MANUAL_CHOICE_ENABLED
2417
= 'login_as_customer/general/store_view_manual_choice_enabled';
2518
private const XML_PATH_AUTHENTICATION_EXPIRATION_TIME
@@ -33,9 +26,8 @@ class Config implements ConfigInterface
3326
/**
3427
* @param ScopeConfigInterface $scopeConfig
3528
*/
36-
public function __construct(
37-
ScopeConfigInterface $scopeConfig
38-
) {
29+
public function __construct(ScopeConfigInterface $scopeConfig)
30+
{
3931
$this->scopeConfig = $scopeConfig;
4032
}
4133

@@ -44,15 +36,15 @@ public function __construct(
4436
*/
4537
public function isEnabled(): bool
4638
{
47-
return (bool)$this->scopeConfig->getValue(self::XML_PATH_ENABLED);
39+
return $this->scopeConfig->isSetFlag(self::XML_PATH_ENABLED);
4840
}
4941

5042
/**
5143
* @inheritdoc
5244
*/
5345
public function isStoreManualChoiceEnabled(): bool
5446
{
55-
return (bool)$this->scopeConfig->getValue(self::XML_PATH_STORE_VIEW_MANUAL_CHOICE_ENABLED);
47+
return $this->scopeConfig->isSetFlag(self::XML_PATH_STORE_VIEW_MANUAL_CHOICE_ENABLED);
5648
}
5749

5850
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup">
12+
<annotations>
13+
<description>Verify Sticky Login as Customer notification banner present on page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="customerFullName" type="string"/>
17+
<argument name="websiteName" type="string" defaultValue="Main Website"/>
18+
</arguments>
19+
20+
<waitForElementVisible selector="{{StorefrontLoginAsCustomerNotificationSection.notificationText}}" stepKey="waitForNotificationBanner"/>
21+
<see selector="{{StorefrontLoginAsCustomerNotificationSection.notificationText}}"
22+
userInput="You are connected as {{customerFullName}} on {{websiteName}}"
23+
stepKey="assertCorrectNotificationBannerMessage"/>
24+
<seeElement selector="{{StorefrontLoginAsCustomerNotificationSection.closeLink}}"
25+
stepKey="assertCloseNotificationBannerPresent"/>
26+
<executeJS function="window.scrollTo(0,document.body.scrollHeight);" stepKey="scrollToBottomOfPage"/>
27+
<see selector="{{StorefrontLoginAsCustomerNotificationSection.notificationText}}"
28+
userInput="You are connected as {{customerFullName}} on {{websiteName}}"
29+
stepKey="assertCorrectNotificationBannerMessageAfterScroll"/>
30+
<seeElement selector="{{StorefrontLoginAsCustomerNotificationSection.closeLink}}"
31+
stepKey="assertCloseNotificationBannerPresentAfterScroll"/>
32+
</actionGroup>
33+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontStickyLoginAsCustomerNotificationBannerTest">
12+
<annotations>
13+
<features value="Login as Customer"/>
14+
<useCaseId value="https://github.com/magento/magento2/issues/29354"/>
15+
<stories value="Availability of sticky UI elements if module enable/disable"/>
16+
<title value="Sticky Notification Banner is present on Storefront page"/>
17+
<description
18+
value="Verify that Sticky Notification Banner is present on page if 'Login as customer' functionality used"/>
19+
<testCaseId value=""/>
20+
<group value="login_as_customer"/>
21+
<severity value="CRITICAL"/>
22+
</annotations>
23+
<before>
24+
<magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 1"
25+
stepKey="enableLoginAsCustomer"/>
26+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanConfigCache">
27+
<argument name="tags" value="config"/>
28+
</actionGroup>
29+
<createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/>
30+
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
31+
</before>
32+
33+
<after>
34+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
35+
<magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 0"
36+
stepKey="disableLoginAsCustomer"/>
37+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanConfigCache">
38+
<argument name="tags" value="config"/>
39+
</actionGroup>
40+
</after>
41+
42+
<actionGroup ref="AdminLoginAsCustomerLoginFromCustomerPageActionGroup" stepKey="loginAsCustomerFromCustomerPage">
43+
<argument name="customerId" value="$$createCustomer.id$$"/>
44+
</actionGroup>
45+
46+
<actionGroup ref="AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup" stepKey="assertStickyNotificationBanner">
47+
<argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/>
48+
</actionGroup>
49+
50+
<actionGroup ref="StorefrontSignOutNotificationBannerAndCloseTabActionGroup" stepKey="signOutAndCloseTab"/>
51+
</test>
52+
</tests>

app/code/Magento/LoginAsCustomerAdminUi/Model/Config/Source/StoreViewLogin.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,7 @@
1212
*/
1313
class StoreViewLogin implements \Magento\Framework\Data\OptionSourceInterface
1414
{
15-
/**
16-
* @const int
17-
*/
1815
private const AUTODETECT = 0;
19-
20-
/**
21-
* @const int
22-
*/
2316
private const MANUAL = 1;
2417

2518
/**

app/code/Magento/LoginAsCustomerAdminUi/Plugin/Button/ToolbarPlugin.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\LoginAsCustomerAdminUi\Plugin\Button;
99

1010
use Magento\Backend\Block\Widget\Button\ButtonList;
11+
use Magento\Backend\Block\Widget\Button\ToolbarInterface;
1112
use Magento\Framework\AuthorizationInterface;
1213
use Magento\Framework\Escaper;
1314
use Magento\Framework\View\Element\AbstractBlock;
@@ -61,13 +62,13 @@ public function __construct(
6162
/**
6263
* Add Login as Customer button.
6364
*
64-
* @param \Magento\Backend\Block\Widget\Button\ToolbarInterface $subject
65-
* @param \Magento\Framework\View\Element\AbstractBlock $context
66-
* @param \Magento\Backend\Block\Widget\Button\ButtonList $buttonList
65+
* @param ToolbarInterface $subject
66+
* @param AbstractBlock $context
67+
* @param ButtonList $buttonList
6768
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6869
*/
6970
public function beforePushButtons(
70-
\Magento\Backend\Block\Widget\Button\ToolbarInterface $subject,
71+
ToolbarInterface $subject,
7172
AbstractBlock $context,
7273
ButtonList $buttonList
7374
): void {
@@ -97,18 +98,17 @@ public function beforePushButtons(
9798
*/
9899
private function getOrder(string $nameInLayout, AbstractBlock $context)
99100
{
100-
$order = null;
101-
102-
if ('sales_order_edit' == $nameInLayout) {
103-
$order = $context->getOrder();
104-
} elseif ('sales_invoice_view' == $nameInLayout) {
105-
$order = $context->getInvoice()->getOrder();
106-
} elseif ('sales_shipment_view' == $nameInLayout) {
107-
$order = $context->getShipment()->getOrder();
108-
} elseif ('sales_creditmemo_view' == $nameInLayout) {
109-
$order = $context->getCreditmemo()->getOrder();
101+
switch ($nameInLayout) {
102+
case 'sales_order_edit':
103+
return $context->getOrder();
104+
case 'sales_invoice_view':
105+
return $context->getInvoice()->getOrder();
106+
case 'sales_shipment_view':
107+
return $context->getShipment()->getOrder();
108+
case 'sales_creditmemo_view':
109+
return $context->getCreditmemo()->getOrder();
110110
}
111111

112-
return $order;
112+
return null;
113113
}
114114
}

app/code/Magento/LoginAsCustomerAssistance/Block/Adminhtml/NotAllowedPopup.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,11 @@
1919
class NotAllowedPopup extends Template
2020
{
2121
/**
22-
* Config
23-
*
2422
* @var ConfigInterface
2523
*/
2624
private $config;
2725

2826
/**
29-
* Json Serializer
30-
*
3127
* @var Json
3228
*/
3329
private $json;

app/code/Magento/LoginAsCustomerAssistance/Model/Config.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
*/
1717
class Config implements ConfigInterface
1818
{
19-
/**
20-
* Extension config path
21-
*/
2219
private const XML_PATH_SHOPPING_ASSISTANCE_CHECKBOX_TITLE
2320
= 'login_as_customer/general/shopping_assistance_checkbox_title';
2421
private const XML_PATH_SHOPPING_ASSISTANCE_CHECKBOX_TOOLTIP

app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\App\RequestInterface;
1212
use Magento\Framework\AuthorizationInterface;
1313
use Magento\Framework\Message\MessageInterface;
14+
use Magento\Framework\Validator\Exception as ValidatorException;
1415
use Magento\LoginAsCustomerAssistance\Api\IsAssistanceEnabledInterface;
1516
use Magento\LoginAsCustomerAssistance\Model\ResourceModel\GetLoginAsCustomerAssistanceAllowed;
1617

@@ -48,7 +49,7 @@ public function __construct(
4849
* @param RequestInterface $request
4950
* @param null|string $scope
5051
* @param bool $scopeOnly
51-
* @throws \Magento\Framework\Validator\Exception
52+
* @throws ValidatorException
5253
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5354
*/
5455
public function beforeExtractData(
@@ -74,11 +75,7 @@ public function beforeExtractData(
7475
],
7576
];
7677

77-
throw new \Magento\Framework\Validator\Exception(
78-
null,
79-
null,
80-
$errorMessages
81-
);
78+
throw new ValidatorException(null, null, $errorMessages);
8279
}
8380
}
8481
}

app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerExtractorPlugin.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,20 @@ public function __construct(
3535
* Add assistance_allowed extension attribute value to Customer instance.
3636
*
3737
* @param CustomerExtractor $subject
38-
* @param callable $proceed
38+
* @param CustomerInterface $customer
3939
* @param string $formCode
4040
* @param RequestInterface $request
4141
* @param array $attributeValues
4242
* @return CustomerInterface
4343
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4444
*/
45-
public function aroundExtract(
45+
public function afterExtract(
4646
CustomerExtractor $subject,
47-
callable $proceed,
47+
CustomerInterface $customer,
4848
string $formCode,
4949
RequestInterface $request,
5050
array $attributeValues = []
5151
) {
52-
/** @var CustomerInterface $customer */
53-
$customer = $proceed(
54-
$formCode,
55-
$request,
56-
$attributeValues
57-
);
58-
5952
$assistanceAllowedStatus = $request->getParam('assistance_allowed');
6053
if (!empty($assistanceAllowedStatus)) {
6154
$extensionAttributes = $customer->getExtensionAttributes();

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,17 @@ public function __construct(
6565
*/
6666
public function beforeExecute(ActionInterface $subject)
6767
{
68-
if ($this->config->isEnabled()) {
69-
$adminId = $this->getLoggedAsCustomerAdminId->execute();
70-
$customerId = (int)$this->session->getCustomerId();
71-
if ($adminId && $customerId) {
72-
if (!$this->isLoginAsCustomerSessionActive->execute($customerId, $adminId)) {
73-
$this->session->clearStorage();
74-
$this->session->expireSessionCookie();
75-
$this->session->regenerateId();
76-
}
68+
if (!$this->config->isEnabled()) {
69+
return;
70+
}
71+
72+
$adminId = $this->getLoggedAsCustomerAdminId->execute();
73+
$customerId = (int)$this->session->getCustomerId();
74+
if ($adminId && $customerId) {
75+
if (!$this->isLoginAsCustomerSessionActive->execute($customerId, $adminId)) {
76+
$this->session->clearStorage();
77+
$this->session->expireSessionCookie();
78+
$this->session->regenerateId();
7779
}
7880
}
7981
}

app/code/Magento/LoginAsCustomerFrontendUi/view/frontend/templates/html/notices.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
$viewFileUrl = $block->getViewFileUrl('Magento_LoginAsCustomerFrontendUi::images/magento-icon.svg');
1212
?>
1313
<?php if ($block->getConfig()->isEnabled()): ?>
14-
<div data-bind="scope: 'loginAsCustomer'" >
14+
<div class="lac-notification-sticky"
15+
data-mage-init='{"sticky":{"container": "body"}}'
16+
data-bind="scope: 'loginAsCustomer'" >
1517
<div class="lac-notification clearfix" data-bind="visible: isVisible" style="display: none">
1618
<div class="top-container">
1719
<div class="lac-notification-icon wrapper">

0 commit comments

Comments
 (0)