Skip to content

Commit 398801c

Browse files
authored
Merge branch '2.4-develop' into community-features-252
2 parents a493bc5 + e12a2fd commit 398801c

File tree

514 files changed

+26403
-275
lines changed

Some content is hidden

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

514 files changed

+26403
-275
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ For more detailed information on contribution please read our [beginners guide](
2323
* Unit/integration test coverage
2424
* Proposed [documentation](https://devdocs.magento.com) updates. Documentation contributions can be submitted via the [devdocs GitHub](https://github.com/magento/devdocs).
2525
4. For larger features or changes, please [open an issue](https://github.com/magento/magento2/issues) to discuss the proposed changes prior to development. This may prevent duplicate or unnecessary effort and allow other contributors to provide input.
26-
5. All automated tests must pass (all builds on [Travis CI](https://travis-ci.org/magento/magento2) must be green).
26+
5. All automated tests must pass.
2727

2828
## Contribution process
2929

.htaccess

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,6 @@
238238
Require all denied
239239
</IfVersion>
240240
</Files>
241-
<Files .travis.yml>
242-
<IfVersion < 2.4>
243-
order allow,deny
244-
deny from all
245-
</IfVersion>
246-
<IfVersion >= 2.4>
247-
Require all denied
248-
</IfVersion>
249-
</Files>
250241
<Files CHANGELOG.md>
251242
<IfVersion < 2.4>
252243
order allow,deny

.htaccess.sample

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,6 @@
238238
Require all denied
239239
</IfVersion>
240240
</Files>
241-
<Files .travis.yml>
242-
<IfVersion < 2.4>
243-
order allow,deny
244-
deny from all
245-
</IfVersion>
246-
<IfVersion >= 2.4>
247-
Require all denied
248-
</IfVersion>
249-
</Files>
250241
<Files CHANGELOG.md>
251242
<IfVersion < 2.4>
252243
order allow,deny

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
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;
15+
use Magento\LoginAsCustomerApi\Api\SetLoggedAsCustomerAdminIdInterface;
1416

1517
/**
1618
* @inheritdoc
@@ -29,16 +31,25 @@ class AuthenticateCustomerBySecret implements AuthenticateCustomerBySecretInterf
2931
*/
3032
private $customerSession;
3133

34+
/**
35+
* @var SetLoggedAsCustomerAdminIdInterface
36+
*/
37+
private $setLoggedAsCustomerAdminId;
38+
3239
/**
3340
* @param GetAuthenticationDataBySecretInterface $getAuthenticationDataBySecret
3441
* @param Session $customerSession
42+
* @param SetLoggedAsCustomerAdminIdInterface $setLoggedAsCustomerAdminId
3543
*/
3644
public function __construct(
3745
GetAuthenticationDataBySecretInterface $getAuthenticationDataBySecret,
38-
Session $customerSession
46+
Session $customerSession,
47+
?SetLoggedAsCustomerAdminIdInterface $setLoggedAsCustomerAdminId = null
3948
) {
4049
$this->getAuthenticationDataBySecret = $getAuthenticationDataBySecret;
4150
$this->customerSession = $customerSession;
51+
$this->setLoggedAsCustomerAdminId = $setLoggedAsCustomerAdminId
52+
?? ObjectManager::getInstance()->get(SetLoggedAsCustomerAdminIdInterface::class);
4253
}
4354

4455
/**
@@ -58,6 +69,6 @@ public function execute(string $secret): void
5869
}
5970

6071
$this->customerSession->regenerateId();
61-
$this->customerSession->setLoggedAsCustomerAdmindId($authenticationData->getAdminId());
72+
$this->setLoggedAsCustomerAdminId->execute($authenticationData->getAdminId());
6273
}
6374
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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\LoginAsCustomer\Model;
9+
10+
use Magento\Customer\Model\Session;
11+
use Magento\LoginAsCustomerApi\Api\GetLoggedAsCustomerAdminIdInterface;
12+
13+
/**
14+
* @inheritdoc
15+
*
16+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
17+
*/
18+
class GetLoggedAsCustomerAdminId implements GetLoggedAsCustomerAdminIdInterface
19+
{
20+
/**
21+
* @var Session
22+
*/
23+
private $session;
24+
25+
/**
26+
* @param Session $session
27+
*/
28+
public function __construct(Session $session)
29+
{
30+
$this->session = $session;
31+
}
32+
33+
/**
34+
* @inheritdoc
35+
*/
36+
public function execute(): int
37+
{
38+
return (int)$this->session->getLoggedAsCustomerAdmindId();
39+
}
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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\LoginAsCustomer\Model;
9+
10+
use Magento\Backend\Model\Auth\Session;
11+
use Magento\LoginAsCustomerApi\Api\GetLoggedAsCustomerCustomerIdInterface;
12+
13+
/**
14+
* @inheritdoc
15+
*
16+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
17+
*/
18+
class GetLoggedAsCustomerCustomerId implements GetLoggedAsCustomerCustomerIdInterface
19+
{
20+
/**
21+
* @var Session
22+
*/
23+
private $session;
24+
25+
/**
26+
* @param Session $session
27+
*/
28+
public function __construct(Session $session)
29+
{
30+
$this->session = $session;
31+
}
32+
33+
/**
34+
* @inheritdoc
35+
*/
36+
public function execute(): int
37+
{
38+
return (int)$this->session->getLoggedAsCustomerCustomerId();
39+
}
40+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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\LoginAsCustomer\Model;
9+
10+
use Magento\LoginAsCustomerApi\Api\ConfigInterface;
11+
use Magento\LoginAsCustomerApi\Api\Data\IsLoginAsCustomerEnabledForCustomerResultInterface;
12+
use Magento\LoginAsCustomerApi\Api\IsLoginAsCustomerEnabledForCustomerInterface;
13+
use Magento\LoginAsCustomerApi\Model\IsLoginAsCustomerEnabledForCustomerResolverInterface;
14+
15+
/**
16+
* @inheritdoc
17+
*/
18+
class IsLoginAsCustomerEnabledForCustomerChain implements IsLoginAsCustomerEnabledForCustomerInterface
19+
{
20+
/**
21+
* @var ConfigInterface
22+
*/
23+
private $config;
24+
25+
/**
26+
* @var IsLoginAsCustomerEnabledForCustomerResultFactory
27+
*/
28+
private $resultFactory;
29+
30+
/**
31+
* @var IsLoginAsCustomerEnabledForCustomerResultInterface[]
32+
*/
33+
private $resolvers;
34+
35+
/**
36+
* @param ConfigInterface $config
37+
* @param IsLoginAsCustomerEnabledForCustomerResultFactory $resultFactory
38+
* @param array $resolvers
39+
*/
40+
public function __construct(
41+
ConfigInterface $config,
42+
IsLoginAsCustomerEnabledForCustomerResultFactory $resultFactory,
43+
array $resolvers = []
44+
) {
45+
$this->config = $config;
46+
$this->resultFactory = $resultFactory;
47+
$this->resolvers = $resolvers;
48+
}
49+
50+
/**
51+
* @inheritdoc
52+
*/
53+
public function execute(int $customerId): IsLoginAsCustomerEnabledForCustomerResultInterface
54+
{
55+
$messages = [[]];
56+
/** @var IsLoginAsCustomerEnabledForCustomerResultInterface $resolver */
57+
foreach ($this->resolvers as $resolver) {
58+
$resolverResult = $resolver->execute($customerId);
59+
if (!$resolverResult->isEnabled()) {
60+
$messages[] = $resolverResult->getMessages();
61+
}
62+
}
63+
64+
return $this->resultFactory->create(['messages' => array_merge(...$messages)]);
65+
}
66+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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\LoginAsCustomer\Model;
9+
10+
use Magento\LoginAsCustomerApi\Api\Data\IsLoginAsCustomerEnabledForCustomerResultInterface;
11+
12+
/**
13+
* @inheritdoc
14+
*/
15+
class IsLoginAsCustomerEnabledForCustomerResult implements IsLoginAsCustomerEnabledForCustomerResultInterface
16+
{
17+
/**
18+
* @var string[]
19+
*/
20+
private $messages;
21+
22+
/**
23+
* @param array $messages
24+
*/
25+
public function __construct(array $messages = [])
26+
{
27+
$this->messages = $messages;
28+
}
29+
30+
/**
31+
* @inheritdoc
32+
*/
33+
public function isEnabled(): bool
34+
{
35+
return empty($this->messages);
36+
}
37+
38+
/**
39+
* @inheritdoc
40+
*/
41+
public function getMessages(): array
42+
{
43+
return $this->messages;
44+
}
45+
46+
/**
47+
* @inheritdoc
48+
*/
49+
public function setMessages(array $messages): void
50+
{
51+
$this->messages = $messages;
52+
}
53+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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\LoginAsCustomer\Model\Resolver;
9+
10+
use Magento\LoginAsCustomer\Model\IsLoginAsCustomerEnabledForCustomerResultFactory;
11+
use Magento\LoginAsCustomerApi\Api\ConfigInterface;
12+
use Magento\LoginAsCustomerApi\Api\Data\IsLoginAsCustomerEnabledForCustomerResultInterface;
13+
use Magento\LoginAsCustomerApi\Api\IsLoginAsCustomerEnabledForCustomerInterface;
14+
15+
/**
16+
* @inheritdoc
17+
*/
18+
class IsLoginAsCustomerEnabledResolver implements IsLoginAsCustomerEnabledForCustomerInterface
19+
{
20+
/**
21+
* @var ConfigInterface
22+
*/
23+
private $config;
24+
25+
/**
26+
* @var IsLoginAsCustomerEnabledForCustomerResultFactory
27+
*/
28+
private $resultFactory;
29+
30+
/**
31+
* @param ConfigInterface $config
32+
* @param IsLoginAsCustomerEnabledForCustomerResultFactory $resultFactory
33+
*/
34+
public function __construct(
35+
ConfigInterface $config,
36+
IsLoginAsCustomerEnabledForCustomerResultFactory $resultFactory
37+
) {
38+
$this->config = $config;
39+
$this->resultFactory = $resultFactory;
40+
}
41+
42+
/**
43+
* @inheritdoc
44+
*/
45+
public function execute(int $customerId): IsLoginAsCustomerEnabledForCustomerResultInterface
46+
{
47+
$messages = [];
48+
if (!$this->config->isEnabled()) {
49+
$messages[] = __('Login as Customer is disabled.');
50+
}
51+
52+
return $this->resultFactory->create(['messages' => $messages]);
53+
}
54+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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\LoginAsCustomer\Model;
9+
10+
use Magento\Customer\Model\Session;
11+
use Magento\LoginAsCustomerApi\Api\SetLoggedAsCustomerAdminIdInterface;
12+
13+
/**
14+
* @inheritdoc
15+
*
16+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
17+
*/
18+
class SetLoggedAsCustomerAdminId implements SetLoggedAsCustomerAdminIdInterface
19+
{
20+
/**
21+
* @var Session
22+
*/
23+
private $session;
24+
25+
/**
26+
* @param Session $session
27+
*/
28+
public function __construct(Session $session)
29+
{
30+
$this->session = $session;
31+
}
32+
33+
/**
34+
* @inheritdoc
35+
*/
36+
public function execute(int $adminId): void
37+
{
38+
$this->session->setLoggedAsCustomerAdmindId($adminId);
39+
}
40+
}

0 commit comments

Comments
 (0)