Skip to content

Commit 57eb24b

Browse files
ihorvansachnaydav
authored andcommitted
[Login As Customer] Replaced protected with private properties and methods
1 parent b93d40d commit 57eb24b

File tree

14 files changed

+36
-65
lines changed

14 files changed

+36
-65
lines changed

app/code/Magento/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Login extends GenericButton implements ButtonProviderInterface
1717
/**
1818
* @var \Magento\Framework\AuthorizationInterface
1919
*/
20-
protected $_authorization;
20+
private $_authorization;
2121

2222
/**
2323
* Constructor

app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Index extends \Magento\Backend\App\Action
1919
/**
2020
* @var \Magento\LoginAsCustomer\Model\Login
2121
*/
22-
protected $loginModel = null;
22+
private $loginModel = null;
2323

2424
/**
2525
* Index constructor.

app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Login.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ class Login extends \Magento\Backend\App\Action
2020
/**
2121
* @var \Magento\LoginAsCustomer\Model\Login
2222
*/
23-
protected $loginModel;
23+
private $loginModel;
2424
/**
2525
* @var \Magento\Backend\Model\Auth\Session
2626
*/
27-
protected $authSession = null;
27+
private $authSession = null;
2828
/**
2929
* @var \Magento\Store\Model\StoreManagerInterface
3030
*/
31-
protected $storeManager = null;
31+
private $storeManager = null;
3232
/**
3333
* @var \Magento\Framework\Url
3434
*/
35-
protected $url = null;
35+
private $url = null;
3636
/**
3737
* @var \Magento\LoginAsCustomer\Model\Config
3838
*/
39-
protected $config = null;
39+
private $config = null;
4040

4141
/**
4242
* Login constructor.

app/code/Magento/LoginAsCustomer/Controller/Login/Index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Index extends \Magento\Framework\App\Action\Action
1313
/**
1414
* @var \Magento\LoginAsCustomer\Model\Login
1515
*/
16-
protected $loginModel = null;
16+
private $loginModel = null;
1717

1818
/**
1919
* Index constructor.
@@ -57,7 +57,7 @@ public function execute()
5757
* Init login info
5858
* @return false || \Magento\LoginAsCustomer\Model\Login
5959
*/
60-
protected function _initLogin()
60+
private function _initLogin()
6161
{
6262
$secret = $this->getRequest()->getParam('secret');
6363
if (!$secret) {

app/code/Magento/LoginAsCustomer/Model/Config.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ class Config
2525
/**
2626
* @var ScopeConfigInterface
2727
*/
28-
protected $scopeConfig;
28+
29+
private $scopeConfig;
2930
/**
3031
* @var \Magento\Framework\App\ProductMetadataInterface
3132
*/
32-
protected $metadata;
33+
private $metadata;
3334

3435
/**
3536
* Config constructor.

app/code/Magento/LoginAsCustomer/Model/Login.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,42 +37,42 @@ class Login extends \Magento\Framework\Model\AbstractModel
3737
/**
3838
* @var \Magento\Customer\Model\CustomerFactory
3939
*/
40-
protected $_customerFactory;
40+
private $_customerFactory;
4141

4242
/**
4343
* @var \Magento\Customer\Model\Customer
4444
*/
45-
protected $_customer;
45+
private $_customer;
4646

4747
/**
4848
* @var \Magento\Customer\Model\Session
4949
*/
50-
protected $_customerSession;
50+
private $_customerSession;
5151

5252
/**
5353
* @var \Magento\Checkout\Model\Session
5454
*/
55-
protected $_checkoutSession;
55+
private $_checkoutSession;
5656

5757
/**
5858
* @var \Magento\Framework\Stdlib\DateTime\DateTime
5959
*/
60-
protected $_dateTime;
60+
private $_dateTime;
6161

6262
/**
6363
* @var \Magento\Framework\Math\Random
6464
*/
65-
protected $_random;
65+
private $_random;
6666

6767
/**
6868
* @var \Magento\Checkout\Model\Cart
6969
*/
70-
protected $cart;
70+
private $cart;
7171

7272
/**
7373
* @var \Magento\Framework\App\Config\ScopeConfigInterface
7474
*/
75-
protected $scopeConfig;
75+
private $scopeConfig;
7676

7777
/**
7878
* Initialize dependencies.
@@ -167,7 +167,7 @@ public function deleteNotUsed()
167167
* Retrieve login datetime point
168168
* @return [type] [description]
169169
*/
170-
protected function getDateTimePoint()
170+
private function getDateTimePoint()
171171
{
172172
return date('Y-m-d H:i:s', $this->_dateTime->gmtTimestamp() - self::TIME_FRAME);
173173
}

app/code/Magento/LoginAsCustomer/Model/PageCache/ConfigPlugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ class ConfigPlugin
1616
*
1717
* @var \Magento\Framework\App\Config\ScopeConfigInterface
1818
*/
19-
protected $_scopeConfig;
19+
private $_scopeConfig;
2020

2121
/**
2222
* @var \Magento\Customer\Model\Session
2323
*/
24-
protected $_customerSession;
24+
private $_customerSession;
2525

2626
/**
2727
* Initialize dependencies.

app/code/Magento/LoginAsCustomer/Plugin/Button/ToolbarPlugin.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ class ToolbarPlugin
2020
/**
2121
* @var \Magento\Framework\AuthorizationInterface
2222
*/
23-
protected $authorization;
23+
private $authorization;
2424

2525
/**
2626
* @var \Magento\Framework\UrlInterface
2727
*/
28-
protected $urlInterface;
28+
private $urlInterface;
2929

3030
/**
3131
* ToolbarPlugin constructor.
@@ -83,7 +83,7 @@ public function beforePushButtons(
8383
*
8484
* @return bool
8585
*/
86-
protected function isAllowed()
86+
private function isAllowed()
8787
{
8888
return $this->authorization->isAllowed('Magento_LoginAsCustomer::login_button');
8989
}

app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/CustomerActions.php

Lines changed: 0 additions & 16 deletions
This file was deleted.

app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/AbstractColumn.php renamed to app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/Login.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,18 @@
1212
use Magento\Framework\UrlInterface;
1313
use Magento\Framework\AuthorizationInterface;
1414

15-
abstract class AbstractColumn extends \Magento\Ui\Component\Listing\Columns\Column
15+
class Login extends \Magento\Ui\Component\Listing\Columns\Column
1616
{
1717

1818
/**
1919
* @var UrlInterface
2020
*/
21-
protected $urlBuilder;
21+
private $urlBuilder;
2222

2323
/**
2424
* @var \Magento\Framework\AuthorizationInterface
2525
*/
26-
protected $_authorization;
27-
28-
protected $sourceColumnName;
26+
private $_authorization;
2927

3028
/**
3129
* @param ContextInterface $context
@@ -59,11 +57,14 @@ public function prepareDataSource(array $dataSource)
5957
if (isset($dataSource['data']['items'])) {
6058
$hidden = !$this->_authorization->isAllowed('Magento_LoginAsCustomer::login_button');
6159
foreach ($dataSource['data']['items'] as &$item) {
62-
if (!empty($item[$this->sourceColumnName])) {
60+
61+
$sourceColumnName = !empty($item['customer_id']) ? 'customer_id' : 'entity_id';
62+
63+
if (!empty($item[$sourceColumnName])) {
6364
$item[$this->getData('name')]['edit'] = [
6465
'href' => $this->urlBuilder->getUrl(
6566
'loginascustomer/login/login',
66-
['customer_id' => $item[$this->sourceColumnName]]
67+
['customer_id' => $item[$sourceColumnName]]
6768
),
6869
'label' => __('Login As Customer'),
6970
'hidden' => $hidden,

0 commit comments

Comments
 (0)