@@ -94,6 +94,12 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel
94
94
*/
95
95
protected $ _customerSession ;
96
96
97
+ /**
98
+ * Date
99
+ * @var \Magento\Framework\Stdlib\DateTime\DateTime
100
+ */
101
+ private $ dateTime ;
102
+
97
103
/**
98
104
* Store manager
99
105
*
@@ -131,6 +137,7 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel
131
137
* @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder
132
138
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
133
139
* @param \Magento\Customer\Model\Session $customerSession
140
+ * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
134
141
* @param CustomerRepositoryInterface $customerRepository
135
142
* @param AccountManagementInterface $customerAccountManagement
136
143
* @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation
@@ -147,6 +154,7 @@ public function __construct(
147
154
\Magento \Framework \Mail \Template \TransportBuilder $ transportBuilder ,
148
155
\Magento \Store \Model \StoreManagerInterface $ storeManager ,
149
156
\Magento \Customer \Model \Session $ customerSession ,
157
+ \Magento \Framework \Stdlib \DateTime \DateTime $ dateTime ,
150
158
CustomerRepositoryInterface $ customerRepository ,
151
159
AccountManagementInterface $ customerAccountManagement ,
152
160
\Magento \Framework \Translate \Inline \StateInterface $ inlineTranslation ,
@@ -159,6 +167,7 @@ public function __construct(
159
167
$ this ->_transportBuilder = $ transportBuilder ;
160
168
$ this ->_storeManager = $ storeManager ;
161
169
$ this ->_customerSession = $ customerSession ;
170
+ $ this ->dateTime = $ dateTime ;
162
171
$ this ->customerRepository = $ customerRepository ;
163
172
$ this ->customerAccountManagement = $ customerAccountManagement ;
164
173
$ this ->inlineTranslation = $ inlineTranslation ;
@@ -810,4 +819,18 @@ public function getSubscriberFullName()
810
819
}
811
820
return $ name ;
812
821
}
822
+
823
+ /**
824
+ * Set date of last changed status
825
+ *
826
+ * @return $this
827
+ */
828
+ public function beforeSave ()
829
+ {
830
+ parent ::beforeSave ();
831
+ if ($ this ->dataHasChangedFor ('subscriber_status ' )) {
832
+ $ this ->setChangeStatusAt ($ this ->dateTime ->gmtDate ());
833
+ }
834
+ return $ this ;
835
+ }
813
836
}
0 commit comments