Skip to content

Commit c7d40ee

Browse files
author
Dmytro Voskoboinikov
committed
MAGETWO-34361: Pull request processing
1 parent 8c7f0f8 commit c7d40ee

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1313

1414
/**
15-
* Adminhtml customer view personal information sales block
15+
* Adminhtml customer view personal information sales block.
16+
*
1617
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1718
*/
1819
class PersonalInfo extends \Magento\Backend\Block\Template
@@ -34,6 +35,11 @@ class PersonalInfo extends \Magento\Backend\Block\Template
3435
*/
3536
protected $customerLog;
3637

38+
/**
39+
* @var \Magento\Customer\Model\Logger
40+
*/
41+
protected $customerLogger;
42+
3743
/**
3844
* @var AccountManagementInterface
3945
*/
@@ -111,12 +117,9 @@ public function __construct(
111117
$this->dateTime = $dateTime;
112118
$this->addressMapper = $addressMapper;
113119
$this->dataObjectHelper = $dataObjectHelper;
120+
$this->customerLogger = $customerLogger;
114121

115122
parent::__construct($context, $data);
116-
117-
$this->customerLog = $customerLogger->get(
118-
$this->getCustomer()->getId()
119-
);
120123
}
121124

122125
/**
@@ -142,6 +145,22 @@ public function getCustomerId()
142145
return $this->coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
143146
}
144147

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+
145164
/**
146165
* Returns customer's created date in the assigned store
147166
*
@@ -286,20 +305,20 @@ public function getStoreLastLoginDateTimezone()
286305
*/
287306
public function getCurrentStatus()
288307
{
289-
if (!$this->customerLog->getLastLoginAt()) {
308+
if (!$this->getCustomerLog()->getLastLoginAt()) {
290309
return __('Offline');
291310
}
292311

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())
295314
) {
296315
return __('Offline');
297316
}
298317

299318
$interval = $this->getOnlineMinutesInterval();
300319

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
303322
) {
304323
return __('Offline');
305324
}
@@ -314,7 +333,7 @@ public function getCurrentStatus()
314333
*/
315334
public function getLastLoginDate()
316335
{
317-
if ($date = $this->customerLog->getLastLoginAt()) {
336+
if ($date = $this->getCustomerLog()->getLastLoginAt()) {
318337
return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true);
319338
}
320339
return __('Never');
@@ -325,7 +344,7 @@ public function getLastLoginDate()
325344
*/
326345
public function getStoreLastLoginDate()
327346
{
328-
if ($date = strtotime($this->customerLog->getLastLoginAt())) {
347+
if ($date = strtotime($this->getCustomerLog()->getLastLoginAt())) {
329348
$date = $this->_localeDate->scopeDate($this->getCustomer()->getStoreId(), $date, true);
330349
return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true);
331350
}

0 commit comments

Comments
 (0)