Skip to content

Commit 930cefc

Browse files
committed
Merge remote-tracking branch 'mainline/2.4-develop' into MC-33394-pr-delivery
2 parents 0191da8 + 1014a94 commit 930cefc

File tree

95 files changed

+2088
-1051
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2088
-1051
lines changed

app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Customer\Model\Address\AddressModelInterface;
99
use Magento\Customer\Model\Address\Mapper;
1010
use Magento\Customer\Model\Metadata\ElementFactory;
11+
use Magento\Directory\Model\Country\Format;
1112
use Magento\Framework\View\Element\AbstractBlock;
1213

1314
/**
@@ -91,6 +92,8 @@ public function setType(\Magento\Framework\DataObject $type)
9192
}
9293

9394
/**
95+
* Get the format of the address
96+
*
9497
* @param AddressModelInterface|null $address
9598
* @return string
9699
* All new code should use renderArray based on Metadata service
@@ -106,8 +109,11 @@ public function getFormat(AddressModelInterface $address = null)
106109
}
107110

108111
/**
109-
* {@inheritdoc}
112+
* Render address
110113
*
114+
* @param AddressModelInterface $address
115+
* @param string|null $format
116+
* @return mixed
111117
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
112118
* @SuppressWarnings(PHPMD.NPathComplexity)
113119
*/
@@ -118,7 +124,7 @@ public function render(AddressModelInterface $address, $format = null)
118124
}
119125

120126
/**
121-
* {@inheritdoc}
127+
* @inheritdoc
122128
*/
123129
public function getFormatArray($addressAttributes = null)
124130
{
@@ -133,8 +139,11 @@ public function getFormatArray($addressAttributes = null)
133139
}
134140

135141
/**
136-
* {@inheritdoc}
142+
* Render address by attribute array
137143
*
144+
* @param array $addressAttributes
145+
* @param Format|null $format
146+
* @return string
138147
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
139148
* @SuppressWarnings(PHPMD.NPathComplexity)
140149
*/
@@ -167,7 +176,7 @@ public function renderArray($addressAttributes, $format = null)
167176
$addressAttributes['country_id']
168177
)->getName();
169178
} elseif ($attributeCode == 'region' && isset($addressAttributes['region'])) {
170-
$data['region'] = __($addressAttributes['region']);
179+
$data['region'] = (string)__($addressAttributes['region']);
171180
} elseif (isset($addressAttributes[$attributeCode])) {
172181
$value = $addressAttributes[$attributeCode];
173182
$dataModel = $this->_elementFactory->create($attributeMetadata, $value, 'customer_address');

app/code/Magento/LoginAsCustomer/Cron/DeleteExpiredAuthenticationData.php

Lines changed: 0 additions & 49 deletions
This file was deleted.

app/code/Magento/LoginAsCustomer/Model/ResourceModel/DeleteExpiredAuthenticationData.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,15 @@ public function __construct(
5050
/**
5151
* @inheritdoc
5252
*/
53-
public function execute(): void
53+
public function execute(int $userId): void
5454
{
5555
$connection = $this->resourceConnection->getConnection();
5656
$tableName = $this->resourceConnection->getTableName('login_as_customer');
5757

58-
$timePoint = date(
59-
'Y-m-d H:i:s',
60-
$this->dateTime->gmtTimestamp() - $this->config->getAuthenticationDataExpirationTime()
61-
);
62-
6358
$connection->delete(
6459
$tableName,
6560
[
66-
'created_at < ?' => $timePoint
61+
'admin_id = ?' => $userId
6762
]
6863
);
6964
}

app/code/Magento/LoginAsCustomer/Model/ResourceModel/GetAuthenticationDataBySecret.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ public function execute(string $secretKey): AuthenticationDataInterface
8585
/** @var AuthenticationDataInterface $authenticationData */
8686
$authenticationData = $this->authenticationDataFactory->create(
8787
[
88-
'customerId' => (int)$data['admin_id'],
89-
'adminId' => (int)$data['customer_id'],
88+
'customerId' => (int)$data['customer_id'],
89+
'adminId' => (int)$data['admin_id'],
9090
'extensionAttributes' => null,
9191
]
9292
);

app/code/Magento/LoginAsCustomer/Model/ResourceModel/DeleteAuthenticationDataBySecret.php renamed to app/code/Magento/LoginAsCustomer/Model/ResourceModel/IsLoginAsCustomerSessionActive.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
namespace Magento\LoginAsCustomer\Model\ResourceModel;
99

1010
use Magento\Framework\App\ResourceConnection;
11-
use Magento\LoginAsCustomerApi\Api\DeleteAuthenticationDataBySecretInterface;
11+
use Magento\LoginAsCustomerApi\Api\IsLoginAsCustomerSessionActiveInterface;
1212

1313
/**
1414
* @inheritdoc
1515
*/
16-
class DeleteAuthenticationDataBySecret implements DeleteAuthenticationDataBySecretInterface
16+
class IsLoginAsCustomerSessionActive implements IsLoginAsCustomerSessionActiveInterface
1717
{
1818
/**
1919
* @var ResourceConnection
@@ -32,16 +32,18 @@ public function __construct(
3232
/**
3333
* @inheritdoc
3434
*/
35-
public function execute(string $secret): void
35+
public function execute(int $customerId, int $userId): bool
3636
{
37-
$connection = $this->resourceConnection->getConnection();
3837
$tableName = $this->resourceConnection->getTableName('login_as_customer');
38+
$connection = $this->resourceConnection->getConnection();
39+
40+
$query = $connection->select()
41+
->from($tableName)
42+
->where('customer_id = ?', $customerId)
43+
->where('admin_id = ?', $userId);
44+
45+
$result = $connection->fetchRow($query);
3946

40-
$connection->delete(
41-
$tableName,
42-
[
43-
'secret = ?' => $secret
44-
]
45-
);
47+
return false !== $result;
4648
}
4749
}

app/code/Magento/LoginAsCustomer/etc/crontab.xml

Lines changed: 0 additions & 16 deletions
This file was deleted.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
<preference for="Magento\LoginAsCustomerApi\Api\DeleteAuthenticationDataBySecretInterface" type="Magento\LoginAsCustomer\Model\ResourceModel\DeleteAuthenticationDataBySecret"/>
1414
<preference for="Magento\LoginAsCustomerApi\Api\DeleteExpiredAuthenticationDataInterface" type="Magento\LoginAsCustomer\Model\ResourceModel\DeleteExpiredAuthenticationData"/>
1515
<preference for="Magento\LoginAsCustomerApi\Api\ConfigInterface" type="Magento\LoginAsCustomer\Model\Config"/>
16+
<preference for="Magento\LoginAsCustomerApi\Api\IsLoginAsCustomerSessionActiveInterface" type="Magento\LoginAsCustomer\Model\ResourceModel\IsLoginAsCustomerSessionActive"/>
1617
</config>

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
interface DeleteExpiredAuthenticationDataInterface
1616
{
1717
/**
18-
* Delete expired authentication data
18+
* Delete expired authentication data by user id.
1919
*
20+
* @param int $userId
2021
* @return void
2122
*/
22-
public function execute(): void;
23+
public function execute(int $userId): void;
2324
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\LoginAsCustomerApi\Api;
9+
10+
/**
11+
* Check if Login as Customer session is still active.
12+
*
13+
* @api
14+
*/
15+
interface IsLoginAsCustomerSessionActiveInterface
16+
{
17+
/**
18+
* Check if Login as Customer session is still active.
19+
*
20+
* @param int $customerId
21+
* @param int $userId
22+
* @return bool
23+
*/
24+
public function execute(int $customerId, int $userId): bool;
25+
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\LoginAsCustomerLog\Api\Data;
9+
10+
use Magento\Framework\Api\ExtensibleDataInterface;
11+
12+
/**
13+
* Data interface for login as customer log.
14+
*
15+
* @api
16+
*/
17+
interface LogInterface extends ExtensibleDataInterface
18+
{
19+
const LOG_ID = 'log_id';
20+
const TIME = 'time';
21+
const CUSTOMER_ID = 'customer_id';
22+
const CUSTOMER_EMAIL = 'customer_email';
23+
const USER_ID = 'user_id';
24+
const USERNAME = 'user_name';
25+
26+
/**
27+
* Set login as customer log id.
28+
*
29+
* @param int $logId
30+
* @return void
31+
*/
32+
public function setLogId(int $logId): void;
33+
34+
/**
35+
* Retrieve login as customer log id.
36+
*
37+
* @return null|int
38+
*/
39+
public function getLogId(): ?int;
40+
41+
/**
42+
* Set login as customer log time.
43+
*
44+
* @param string $time
45+
* @return void
46+
*/
47+
public function setTime(string $time): void;
48+
49+
/**
50+
* Retrieve login as customer log time.
51+
*
52+
* @return null|string
53+
*/
54+
public function getTime(): ?string;
55+
56+
/**
57+
* Set login as customer log user id.
58+
*
59+
* @param int $userId
60+
* @return void
61+
*/
62+
public function setUserId(int $userId): void;
63+
64+
/**
65+
* Retrieve login as customer log user id.
66+
*
67+
* @return null|int
68+
*/
69+
public function getUserId(): ?int;
70+
71+
/**
72+
* Set login as customer log user name.
73+
*
74+
* @param string $userName
75+
* @return void
76+
*/
77+
public function setUserName(string $userName): void;
78+
79+
/**
80+
* Retrieve login as customer log user name.
81+
*
82+
* @return null|string
83+
*/
84+
public function getUserName(): ?string;
85+
86+
/**
87+
* Set login as customer log customer id.
88+
*
89+
* @param int $customerId
90+
* @return void
91+
*/
92+
public function setCustomerId(int $customerId): void;
93+
94+
/**
95+
* Retrieve login as customer log customer id.
96+
*
97+
* @return null|int
98+
*/
99+
public function getCustomerId(): ?int;
100+
101+
/**
102+
* Set login as customer log customer email.
103+
*
104+
* @param string $customerEmail
105+
* @return void
106+
*/
107+
public function setCustomerEmail(string $customerEmail): void;
108+
109+
/**
110+
* Retrieve login as customer log customer email.
111+
*
112+
* @return null|string
113+
*/
114+
public function getCustomerEmail(): ?string;
115+
116+
/**
117+
* Set log extension attributes.
118+
*
119+
* @param \Magento\LoginAsCustomerLog\Api\Data\LogExtensionInterface $extensionAttributes
120+
* @return void
121+
*/
122+
public function setExtensionAttributes(LogExtensionInterface $extensionAttributes): void;
123+
124+
/**
125+
* Retrieve log extension attributes.
126+
*
127+
* @return \Magento\LoginAsCustomerLog\Api\Data\LogExtensionInterface
128+
*/
129+
public function getExtensionAttributes(): LogExtensionInterface;
130+
}

0 commit comments

Comments
 (0)