Skip to content

Commit b3fe5f8

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-90801' into 2.3-develop-pr19
2 parents d2e2e18 + 780e91d commit b3fe5f8

File tree

24 files changed

+996
-290
lines changed

24 files changed

+996
-290
lines changed

app/code/Magento/Checkout/Block/Registration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function getEmailAddress()
9191
*/
9292
public function getCreateAccountUrl()
9393
{
94-
return $this->getUrl('checkout/account/create');
94+
return $this->getUrl('checkout/account/delegateCreate');
9595
}
9696

9797
/**

app/code/Magento/Checkout/Controller/Account/Create.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
use Magento\Framework\Exception\AlreadyExistsException;
1010
use Magento\Framework\Exception\NoSuchEntityException;
1111

12+
/**
13+
* @deprecated
14+
* @see DelegateCreate
15+
*/
1216
class Create extends \Magento\Framework\App\Action\Action
1317
{
1418
/**
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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\Checkout\Controller\Account;
9+
10+
use Magento\Framework\App\Action\Action;
11+
use Magento\Framework\App\Action\Context;
12+
use Magento\Checkout\Model\Session;
13+
use Magento\Sales\Api\OrderCustomerDelegateInterface;
14+
15+
/**
16+
* Redirect guest customer for registration.
17+
*/
18+
class DelegateCreate extends Action
19+
{
20+
/**
21+
* @var OrderCustomerDelegateInterface
22+
*/
23+
private $delegateService;
24+
25+
/**
26+
* @var Session
27+
*/
28+
private $session;
29+
30+
/**
31+
* @param Context $context
32+
* @param OrderCustomerDelegateInterface $customerDelegation
33+
* @param Session $session
34+
*/
35+
public function __construct(
36+
Context $context,
37+
OrderCustomerDelegateInterface $customerDelegation,
38+
Session $session
39+
) {
40+
parent::__construct($context);
41+
$this->delegateService = $customerDelegation;
42+
$this->session = $session;
43+
}
44+
45+
/**
46+
* {@inheritdoc}
47+
*/
48+
public function execute()
49+
{
50+
/** @var string|null $orderId */
51+
$orderId = $this->session->getLastOrderId();
52+
if (!$orderId) {
53+
return $this->resultRedirectFactory->create()->setPath('/');
54+
}
55+
56+
return $this->delegateService->delegateNew((int)$orderId);
57+
}
58+
}

app/code/Magento/Checkout/view/frontend/web/js/view/registration.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,16 @@ define([
3838
},
3939

4040
/**
41-
* Create new user account
41+
* @return String
42+
*/
43+
getUrl: function () {
44+
return this.registrationUrl;
45+
},
46+
47+
/**
48+
* Create new user account.
49+
*
50+
* @deprecated
4251
*/
4352
createAccount: function () {
4453
this.creationStarted(true);

app/code/Magento/Checkout/view/frontend/web/template/registration.html

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@
1111
<!-- ko if: isFormVisible -->
1212
<p data-bind="i18n: 'You can track your order status by creating an account.'"></p>
1313
<p><span data-bind="i18n: 'Email Address'"></span>: <span data-bind="text: getEmailAddress()"></span></p>
14-
<form method="post" data-bind="submit: createAccount">
15-
<input type="submit" class="action primary" data-bind="value: $t('Create an Account'), disable: creationStarted" />
14+
<form method="get" data-bind="attr: { action: getUrl() }">
15+
<input type="submit" class="action primary" data-bind="value: $t('Create an Account')" />
1616
</form>
17-
<!-- /ko -->
18-
<!-- ko if: accountCreated -->
19-
<p data-bind="i18n: 'A letter with further instructions will be sent to your email.'"></p>
20-
<!-- /ko -->
17+
<!--/ko-->
2118
</div>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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\Customer\Api;
9+
10+
use Magento\Customer\Api\Data\CustomerInterface;
11+
use Magento\Framework\Controller\Result\Redirect;
12+
13+
/**
14+
* Delegating account actions from outside of customer module.
15+
*/
16+
interface AccountDelegationInterface
17+
{
18+
/**
19+
* Create redirect to default new account form.
20+
*
21+
* @param CustomerInterface $customer Pre-filled customer data.
22+
* @param array|null $mixedData Add this data to new-customer event
23+
* if the new customer is created.
24+
*
25+
* @return Redirect
26+
*/
27+
public function createRedirectForNew(
28+
CustomerInterface $customer,
29+
array $mixedData = null
30+
): Redirect;
31+
}
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\Customer\Model\Delegation;
9+
10+
use Magento\Customer\Api\Data\CustomerInterface;
11+
use Magento\Customer\Api\AccountDelegationInterface;
12+
use Magento\Framework\Controller\Result\Redirect;
13+
use Magento\Framework\Controller\Result\RedirectFactory;
14+
15+
/**
16+
* {@inheritdoc}
17+
*/
18+
class AccountDelegation implements AccountDelegationInterface
19+
{
20+
/**
21+
* @var RedirectFactory
22+
*/
23+
private $redirectFactory;
24+
25+
/**
26+
* @var Storage
27+
*/
28+
private $storage;
29+
30+
/**
31+
* @param RedirectFactory $redirectFactory
32+
* @param Storage $storage
33+
*/
34+
public function __construct(
35+
RedirectFactory $redirectFactory,
36+
Storage $storage
37+
) {
38+
$this->redirectFactory = $redirectFactory;
39+
$this->storage = $storage;
40+
}
41+
42+
/**
43+
* {@inheritdoc}
44+
*/
45+
public function createRedirectForNew(
46+
CustomerInterface $customer,
47+
array $mixedData = null
48+
): Redirect {
49+
$this->storage->storeNewOperation($customer, $mixedData);
50+
51+
return $this->redirectFactory->create()->setPath('customer/account/create');
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\Customer\Model\Delegation\Data;
9+
10+
use Magento\Customer\Api\Data\CustomerInterface;
11+
12+
/**
13+
* Data required for delegated new-account operation.
14+
*/
15+
class NewOperation
16+
{
17+
/**
18+
* @var CustomerInterface
19+
*/
20+
private $customer;
21+
22+
/**
23+
* @var array
24+
*/
25+
private $additionalData;
26+
27+
/**
28+
* @param CustomerInterface $customer
29+
* @param array $additionalData
30+
*/
31+
public function __construct(
32+
CustomerInterface $customer,
33+
array $additionalData
34+
) {
35+
$this->customer = $customer;
36+
$this->additionalData = $additionalData;
37+
}
38+
39+
/**
40+
* @return CustomerInterface
41+
*/
42+
public function getCustomer(): CustomerInterface
43+
{
44+
return $this->customer;
45+
}
46+
47+
/**
48+
* @return array
49+
*/
50+
public function getAdditionalData(): array
51+
{
52+
return $this->additionalData;
53+
}
54+
}

0 commit comments

Comments
 (0)