Skip to content

Commit c7a2450

Browse files
authored
Merge pull request #5114 from magento-tsg-csl3/MC-4242
[TSG-CSL3] For 2.4 (MC-4242)
2 parents ad6c093 + 18500e1 commit c7a2450

File tree

41 files changed

+3879
-1724
lines changed

Some content is hidden

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

41 files changed

+3879
-1724
lines changed

app/code/Magento/Customer/Block/Account/Dashboard.php

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,35 @@
77

88
use Magento\Customer\Api\AccountManagementInterface;
99
use Magento\Customer\Api\CustomerRepositoryInterface;
10+
use Magento\Customer\Api\Data\AddressInterface;
11+
use Magento\Customer\Api\Data\CustomerInterface;
12+
use Magento\Customer\Model\Session;
13+
use Magento\Framework\Phrase;
14+
use Magento\Framework\View\Element\Template;
15+
use Magento\Framework\View\Element\Template\Context;
16+
use Magento\Newsletter\Model\Subscriber;
17+
use Magento\Newsletter\Model\SubscriberFactory;
1018

1119
/**
1220
* Customer dashboard block
1321
*
1422
* @api
1523
* @since 100.0.2
1624
*/
17-
class Dashboard extends \Magento\Framework\View\Element\Template
25+
class Dashboard extends Template
1826
{
1927
/**
20-
* @var \Magento\Newsletter\Model\Subscriber
28+
* @var Subscriber
2129
*/
2230
protected $subscription;
2331

2432
/**
25-
* @var \Magento\Customer\Model\Session
33+
* @var Session
2634
*/
2735
protected $customerSession;
2836

2937
/**
30-
* @var \Magento\Newsletter\Model\SubscriberFactory
38+
* @var SubscriberFactory
3139
*/
3240
protected $subscriberFactory;
3341

@@ -42,19 +50,17 @@ class Dashboard extends \Magento\Framework\View\Element\Template
4250
protected $customerAccountManagement;
4351

4452
/**
45-
* Constructor
46-
*
47-
* @param \Magento\Framework\View\Element\Template\Context $context
48-
* @param \Magento\Customer\Model\Session $customerSession
49-
* @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory
53+
* @param Context $context
54+
* @param Session $customerSession
55+
* @param SubscriberFactory $subscriberFactory
5056
* @param CustomerRepositoryInterface $customerRepository
5157
* @param AccountManagementInterface $customerAccountManagement
5258
* @param array $data
5359
*/
5460
public function __construct(
55-
\Magento\Framework\View\Element\Template\Context $context,
56-
\Magento\Customer\Model\Session $customerSession,
57-
\Magento\Newsletter\Model\SubscriberFactory $subscriberFactory,
61+
Context $context,
62+
Session $customerSession,
63+
SubscriberFactory $subscriberFactory,
5864
CustomerRepositoryInterface $customerRepository,
5965
AccountManagementInterface $customerAccountManagement,
6066
array $data = []
@@ -69,7 +75,7 @@ public function __construct(
6975
/**
7076
* Return the Customer given the customer Id stored in the session.
7177
*
72-
* @return \Magento\Customer\Api\Data\CustomerInterface
78+
* @return CustomerInterface
7379
*/
7480
public function getCustomer()
7581
{
@@ -99,7 +105,7 @@ public function getAddressesUrl()
99105
/**
100106
* Retrieve the Url for editing the specified address.
101107
*
102-
* @param \Magento\Customer\Api\Data\AddressInterface $address
108+
* @param AddressInterface $address
103109
* @return string
104110
*/
105111
public function getAddressEditUrl($address)
@@ -146,13 +152,14 @@ public function getWishlistUrl()
146152
/**
147153
* Retrieve the subscription object (i.e. the subscriber).
148154
*
149-
* @return \Magento\Newsletter\Model\Subscriber
155+
* @return Subscriber
150156
*/
151157
public function getSubscriptionObject()
152158
{
153159
if ($this->subscription === null) {
154-
$this->subscription =
155-
$this->_createSubscriber()->loadByCustomerId($this->customerSession->getCustomerId());
160+
$websiteId = (int)$this->_storeManager->getWebsite()->getId();
161+
$this->subscription = $this->_createSubscriber();
162+
$this->subscription->loadByCustomer((int)$this->getCustomer()->getId(), $websiteId);
156163
}
157164

158165
return $this->subscription;
@@ -171,7 +178,7 @@ public function getManageNewsletterUrl()
171178
/**
172179
* Retrieve subscription text, either subscribed or not.
173180
*
174-
* @return \Magento\Framework\Phrase
181+
* @return Phrase
175182
*/
176183
public function getSubscriptionText()
177184
{
@@ -185,7 +192,7 @@ public function getSubscriptionText()
185192
/**
186193
* Retrieve the customer's primary addresses (i.e. default billing and shipping).
187194
*
188-
* @return \Magento\Customer\Api\Data\AddressInterface[]|bool
195+
* @return AddressInterface[]|bool
189196
*/
190197
public function getPrimaryAddresses()
191198
{
@@ -230,7 +237,7 @@ public function getBackUrl()
230237
/**
231238
* Create an instance of a subscriber.
232239
*
233-
* @return \Magento\Newsletter\Model\Subscriber
240+
* @return Subscriber
234241
*/
235242
protected function _createSubscriber()
236243
{

app/code/Magento/Customer/Block/Account/Dashboard/Info.php

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,60 @@
55
*/
66
namespace Magento\Customer\Block\Account\Dashboard;
77

8+
use Magento\Customer\Api\Data\CustomerInterface;
9+
use Magento\Customer\Block\Form\Register;
10+
use Magento\Customer\Helper\Session\CurrentCustomer;
11+
use Magento\Customer\Helper\View;
812
use Magento\Framework\Exception\NoSuchEntityException;
13+
use Magento\Framework\View\Element\Template;
14+
use Magento\Framework\View\Element\Template\Context;
15+
use Magento\Newsletter\Model\Subscriber;
16+
use Magento\Newsletter\Model\SubscriberFactory;
917

1018
/**
1119
* Dashboard Customer Info
1220
*
1321
* @api
1422
* @since 100.0.2
1523
*/
16-
class Info extends \Magento\Framework\View\Element\Template
24+
class Info extends Template
1725
{
1826
/**
1927
* Cached subscription object
2028
*
21-
* @var \Magento\Newsletter\Model\Subscriber
29+
* @var Subscriber
2230
*/
2331
protected $_subscription;
2432

2533
/**
26-
* @var \Magento\Newsletter\Model\SubscriberFactory
34+
* @var SubscriberFactory
2735
*/
2836
protected $_subscriberFactory;
2937

3038
/**
31-
* @var \Magento\Customer\Helper\View
39+
* @var View
3240
*/
3341
protected $_helperView;
3442

3543
/**
36-
* @var \Magento\Customer\Helper\Session\CurrentCustomer
44+
* @var CurrentCustomer
3745
*/
3846
protected $currentCustomer;
3947

4048
/**
4149
* Constructor
4250
*
43-
* @param \Magento\Framework\View\Element\Template\Context $context
44-
* @param \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer
45-
* @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory
46-
* @param \Magento\Customer\Helper\View $helperView
51+
* @param Context $context
52+
* @param CurrentCustomer $currentCustomer
53+
* @param SubscriberFactory $subscriberFactory
54+
* @param View $helperView
4755
* @param array $data
4856
*/
4957
public function __construct(
50-
\Magento\Framework\View\Element\Template\Context $context,
51-
\Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer,
52-
\Magento\Newsletter\Model\SubscriberFactory $subscriberFactory,
53-
\Magento\Customer\Helper\View $helperView,
58+
Context $context,
59+
CurrentCustomer $currentCustomer,
60+
SubscriberFactory $subscriberFactory,
61+
View $helperView,
5462
array $data = []
5563
) {
5664
$this->currentCustomer = $currentCustomer;
@@ -62,7 +70,7 @@ public function __construct(
6270
/**
6371
* Returns the Magento Customer Model for this block
6472
*
65-
* @return \Magento\Customer\Api\Data\CustomerInterface|null
73+
* @return CustomerInterface|null
6674
*/
6775
public function getCustomer()
6876
{
@@ -84,6 +92,8 @@ public function getName()
8492
}
8593

8694
/**
95+
* Get the url to change password
96+
*
8797
* @return string
8898
*/
8999
public function getChangePasswordUrl()
@@ -94,15 +104,16 @@ public function getChangePasswordUrl()
94104
/**
95105
* Get Customer Subscription Object Information
96106
*
97-
* @return \Magento\Newsletter\Model\Subscriber
107+
* @return Subscriber
98108
*/
99109
public function getSubscriptionObject()
100110
{
101111
if (!$this->_subscription) {
102112
$this->_subscription = $this->_createSubscriber();
103113
$customer = $this->getCustomer();
104114
if ($customer) {
105-
$this->_subscription->loadByCustomerId($customer->getId());
115+
$websiteId = (int)$this->_storeManager->getWebsite()->getId();
116+
$this->_subscription->loadByCustomer((int)$customer->getId(), $websiteId);
106117
}
107118
}
108119
return $this->_subscription;
@@ -128,20 +139,22 @@ public function getIsSubscribed()
128139
public function isNewsletterEnabled()
129140
{
130141
return $this->getLayout()
131-
->getBlockSingleton(\Magento\Customer\Block\Form\Register::class)
142+
->getBlockSingleton(Register::class)
132143
->isNewsletterEnabled();
133144
}
134145

135146
/**
136-
* @return \Magento\Newsletter\Model\Subscriber
147+
* Create new instance of Subscriber
148+
*
149+
* @return Subscriber
137150
*/
138151
protected function _createSubscriber()
139152
{
140153
return $this->_subscriberFactory->create();
141154
}
142155

143156
/**
144-
* @return string
157+
* @inheritdoc
145158
*/
146159
protected function _toHtml()
147160
{

0 commit comments

Comments
 (0)