Skip to content

Commit 16bd2a0

Browse files
committed
MAGETWO-34361: Pull request processing
1 parent a91d971 commit 16bd2a0

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class PersonalInfo extends \Magento\Backend\Block\Template
8686
* @param \Magento\Framework\Registry $registry
8787
* @param Mapper $addressMapper
8888
* @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
89-
* @param \Magento\Customer\Model\Log $customerLog
89+
* @param \Magento\Customer\Model\Logger $customerLogger
9090
* @param array $data
9191
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
9292
*/
@@ -286,9 +286,6 @@ public function getStoreLastLoginDateTimezone()
286286
*/
287287
public function getCurrentStatus()
288288
{
289-
if (!$this->customerLog->getCustomerId()) {
290-
return __('Offline');
291-
}
292289
if (!$this->customerLog->getLastLoginAt()) {
293290
return __('Offline');
294291
}

app/code/Magento/Customer/Model/Logger.php

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,29 @@ public function log($customerId, array $data)
6868
* Load log by Customer Id.
6969
*
7070
* @param int $customerId
71-
* @return \Magento\Customer\Model\Log
72-
* @throws \LogicException
71+
* @return Log
7372
*/
74-
public function get($customerId)
73+
public function get($customerId = null)
74+
{
75+
if (null !== $customerId) {
76+
$data = $this->loadLogData($customerId);
77+
}
78+
79+
return $this->logFactory->create(
80+
[
81+
'customerId' => isset($data['customer_id']) ? $data['customer_id'] : null,
82+
'lastLoginAt' => isset($data['last_login_at']) ? $data['last_login_at'] : null,
83+
'lastLogoutAt' => isset($data['last_logout_at']) ? $data['last_logout_at'] : null,
84+
'lastVisitAt' => isset($data['last_visit_at']) ? $data['last_visit_at'] : null
85+
]
86+
);
87+
}
88+
89+
/**
90+
* @param int $customerId
91+
* @return array
92+
*/
93+
protected function loadLogData($customerId)
7594
{
7695
/** @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter */
7796
$adapter = $this->resource->getConnection('read');
@@ -93,20 +112,6 @@ public function get($customerId)
93112
)
94113
->limit(1);
95114

96-
$data = $adapter->fetchRow($select);
97-
98-
if (!$data) {
99-
//throw new \LogicException('Unable to load customer log');
100-
return $this->logFactory->create([]);
101-
}
102-
103-
return $this->logFactory->create(
104-
[
105-
'customerId' => $data['customer_id'],
106-
'lastLoginAt' => $data['last_login_at'],
107-
'lastLogoutAt' => $data['last_logout_at'],
108-
'lastVisitAt' => $data['last_visit_at'],
109-
]
110-
);
115+
return $adapter->fetchRow($select);
111116
}
112117
}

0 commit comments

Comments
 (0)