12
12
use Magento \Framework \Stdlib \DateTime \TimezoneInterface ;
13
13
14
14
/**
15
- * Adminhtml customer view personal information sales block
15
+ * Adminhtml customer view personal information sales block.
16
+ *
16
17
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
17
18
*/
18
19
class PersonalInfo extends \Magento \Backend \Block \Template
@@ -34,6 +35,11 @@ class PersonalInfo extends \Magento\Backend\Block\Template
34
35
*/
35
36
protected $ customerLog ;
36
37
38
+ /**
39
+ * @var \Magento\Customer\Model\Logger
40
+ */
41
+ protected $ customerLogger ;
42
+
37
43
/**
38
44
* @var AccountManagementInterface
39
45
*/
@@ -111,12 +117,9 @@ public function __construct(
111
117
$ this ->dateTime = $ dateTime ;
112
118
$ this ->addressMapper = $ addressMapper ;
113
119
$ this ->dataObjectHelper = $ dataObjectHelper ;
120
+ $ this ->customerLogger = $ customerLogger ;
114
121
115
122
parent ::__construct ($ context , $ data );
116
-
117
- $ this ->customerLog = $ customerLogger ->get (
118
- $ this ->getCustomer ()->getId ()
119
- );
120
123
}
121
124
122
125
/**
@@ -142,6 +145,22 @@ public function getCustomerId()
142
145
return $ this ->coreRegistry ->registry (RegistryConstants::CURRENT_CUSTOMER_ID );
143
146
}
144
147
148
+ /**
149
+ * Retrieves customer log.
150
+ *
151
+ * @return \Magento\Customer\Model\Log
152
+ */
153
+ public function getCustomerLog ()
154
+ {
155
+ if (!$ this ->customerLog ) {
156
+ $ this ->customerLog = $ this ->customerLogger ->get (
157
+ $ this ->getCustomer ()->getId ()
158
+ );
159
+ }
160
+
161
+ return $ this ->customerLog ;
162
+ }
163
+
145
164
/**
146
165
* Returns customer's created date in the assigned store
147
166
*
@@ -286,20 +305,20 @@ public function getStoreLastLoginDateTimezone()
286
305
*/
287
306
public function getCurrentStatus ()
288
307
{
289
- if (!$ this ->customerLog ->getLastLoginAt ()) {
308
+ if (!$ this ->getCustomerLog () ->getLastLoginAt ()) {
290
309
return __ ('Offline ' );
291
310
}
292
311
293
- if ($ this ->customerLog ->getLastLogoutAt () &&
294
- strtotime ($ this ->customerLog ->getLastLogoutAt ()) > strtotime ($ this ->customerLog ->getLastLoginAt ())
312
+ if ($ this ->getCustomerLog () ->getLastLogoutAt () &&
313
+ strtotime ($ this ->getCustomerLog () ->getLastLogoutAt ()) > strtotime ($ this ->getCustomerLog () ->getLastLoginAt ())
295
314
) {
296
315
return __ ('Offline ' );
297
316
}
298
317
299
318
$ interval = $ this ->getOnlineMinutesInterval ();
300
319
301
- if ($ this ->customerLog ->getLastVisitAt () &&
302
- strtotime ($ this ->dateTime ->now ()) - strtotime ($ this ->customerLog ->getLastVisitAt ()) > $ interval * 60
320
+ if ($ this ->getCustomerLog () ->getLastVisitAt () &&
321
+ strtotime ($ this ->dateTime ->now ()) - strtotime ($ this ->getCustomerLog () ->getLastVisitAt ()) > $ interval * 60
303
322
) {
304
323
return __ ('Offline ' );
305
324
}
@@ -314,7 +333,7 @@ public function getCurrentStatus()
314
333
*/
315
334
public function getLastLoginDate ()
316
335
{
317
- if ($ date = $ this ->customerLog ->getLastLoginAt ()) {
336
+ if ($ date = $ this ->getCustomerLog () ->getLastLoginAt ()) {
318
337
return $ this ->formatDate ($ date , TimezoneInterface::FORMAT_TYPE_MEDIUM , true );
319
338
}
320
339
return __ ('Never ' );
@@ -325,7 +344,7 @@ public function getLastLoginDate()
325
344
*/
326
345
public function getStoreLastLoginDate ()
327
346
{
328
- if ($ date = strtotime ($ this ->customerLog ->getLastLoginAt ())) {
347
+ if ($ date = strtotime ($ this ->getCustomerLog () ->getLastLoginAt ())) {
329
348
$ date = $ this ->_localeDate ->scopeDate ($ this ->getCustomer ()->getStoreId (), $ date , true );
330
349
return $ this ->formatDate ($ date , TimezoneInterface::FORMAT_TYPE_MEDIUM , true );
331
350
}
0 commit comments