Skip to content

Commit 60a698d

Browse files
author
Oleksii Korshenko
committed
MAGETWO-83257: #4004: Newsletter Subscriber create-date not set, and change_status_at broken #11879
- fixed backward compatibility issue
1 parent 8fcee2c commit 60a698d

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

app/code/Magento/Newsletter/Model/Subscriber.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
use Magento\Customer\Api\AccountManagementInterface;
99
use Magento\Customer\Api\CustomerRepositoryInterface;
10+
use Magento\Framework\App\ObjectManager;
1011
use Magento\Framework\Exception\MailException;
1112
use Magento\Framework\Exception\NoSuchEntityException;
13+
use Magento\Framework\Stdlib\DateTime\DateTime;
1214

1315
/**
1416
* Subscriber model
@@ -96,7 +98,7 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel
9698

9799
/**
98100
* Date
99-
* @var \Magento\Framework\Stdlib\DateTime\DateTime
101+
* @var DateTime
100102
*/
101103
private $dateTime;
102104

@@ -137,13 +139,13 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel
137139
* @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder
138140
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
139141
* @param \Magento\Customer\Model\Session $customerSession
140-
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
141142
* @param CustomerRepositoryInterface $customerRepository
142143
* @param AccountManagementInterface $customerAccountManagement
143144
* @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation
144-
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
145-
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
145+
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
146+
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
146147
* @param array $data
148+
* @param DateTime|null $dateTime
147149
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
148150
*/
149151
public function __construct(
@@ -154,23 +156,23 @@ public function __construct(
154156
\Magento\Framework\Mail\Template\TransportBuilder $transportBuilder,
155157
\Magento\Store\Model\StoreManagerInterface $storeManager,
156158
\Magento\Customer\Model\Session $customerSession,
157-
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
158159
CustomerRepositoryInterface $customerRepository,
159160
AccountManagementInterface $customerAccountManagement,
160161
\Magento\Framework\Translate\Inline\StateInterface $inlineTranslation,
161162
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
162163
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
163-
array $data = []
164+
array $data = [],
165+
DateTime $dateTime = null
164166
) {
165167
$this->_newsletterData = $newsletterData;
166168
$this->_scopeConfig = $scopeConfig;
167169
$this->_transportBuilder = $transportBuilder;
168170
$this->_storeManager = $storeManager;
169171
$this->_customerSession = $customerSession;
170-
$this->dateTime = $dateTime;
171172
$this->customerRepository = $customerRepository;
172173
$this->customerAccountManagement = $customerAccountManagement;
173174
$this->inlineTranslation = $inlineTranslation;
175+
$this->dateTime = $dateTime ?: ObjectManager::getInstance()->get(DateTime::class);
174176
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
175177
}
176178

0 commit comments

Comments
 (0)