Skip to content

Commit 080a624

Browse files
magento2-login-as-customer/issues/90: Static tests fix.
1 parent 15c9e22 commit 080a624

File tree

7 files changed

+29
-32
lines changed

7 files changed

+29
-32
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function execute(): ResultInterface
100100

101101
$customerStoreId = $request->getParam('store_id');
102102

103-
if (!isset($customerStoreId) && $this->config->getStoreViewLogin()) {
103+
if (!isset($customerStoreId) && $this->config->isManualChoiceEnabled()) {
104104
$this->messageManager->addNoticeMessage(__('Please select a Store View to login in.'));
105105
return $resultRedirect->setPath('loginascustomer/login/manual', ['entity_id' => $customerId ]);
106106
}

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

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
namespace Magento\LoginAsCustomer\Model;
99

1010
use Magento\Framework\App\Config\ScopeConfigInterface;
11-
use Magento\Store\Model\ScopeInterface;
1211
use Magento\Framework\App\ProductMetadataInterface;
12+
use Magento\Store\Model\ScopeInterface;
1313

1414
/**
15-
* Class Config
15+
* LoginAsCustomer module config model.
1616
*/
1717
class Config
1818
{
1919
/**
2020
* Extension config path
2121
*/
2222
private const XML_PATH_EXTENSION_ENABLED = 'loginascustomer/general/enabled';
23-
private const STORE_VIEW_TO_LOGIN_IN = 'loginascustomer/general/store_view_login';
23+
private const ENABLE_STORE_VIEW_MANUAL_CHOICE = 'loginascustomer/general/enable_store_view_manual_choice';
2424

2525
/**
2626
* @var ScopeConfigInterface
@@ -34,7 +34,6 @@ class Config
3434
private $metadata;
3535

3636
/**
37-
* Config constructor.
3837
* @param ScopeConfigInterface $scopeConfig
3938
* @param ProductMetadataInterface $metadata
4039
*/
@@ -47,37 +46,30 @@ public function __construct(
4746
}
4847

4948
/**
50-
* Retrieve store config value
51-
* @param string $path
52-
* @param null $storeId
53-
* @return mixed
54-
*/
55-
public function getConfig($path, $storeId = null)
56-
{
57-
return $this->scopeConfig->getValue(
58-
$path,
59-
ScopeInterface::SCOPE_STORE,
60-
$storeId
61-
);
62-
}
63-
64-
/**
49+
* Check if Login As Customer extension is enabled.
50+
*
6551
* @return bool
6652
*/
6753
public function isEnabled(): bool
6854
{
69-
return (bool)$this->getConfig(
70-
self::XML_PATH_EXTENSION_ENABLED
55+
return (bool)$this->scopeConfig->getValue(
56+
self::XML_PATH_EXTENSION_ENABLED,
57+
ScopeInterface::SCOPE_STORE,
58+
null
7159
);
7260
}
7361

7462
/**
63+
* Check if store view manual choice is enabled.
64+
*
7565
* @return bool
7666
*/
77-
public function getStoreViewLogin(): bool
67+
public function isManualChoiceEnabled(): bool
7868
{
79-
return (bool)$this->getConfig(
80-
self::STORE_VIEW_TO_LOGIN_IN
69+
return (bool)$this->scopeConfig->getValue(
70+
self::ENABLE_STORE_VIEW_MANUAL_CHOICE,
71+
ScopeInterface::SCOPE_STORE,
72+
null
8173
);
8274
}
8375
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
/**
1111
* Page cache config plugin
12+
*
13+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1214
*/
1315
class ConfigPlugin
1416
{
@@ -44,10 +46,12 @@ public function __construct(
4446
* @param \Magento\PageCache\Model\Config $subject
4547
* @param bool $result
4648
* @return bool
49+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4750
*/
4851
public function afterIsEnabled(\Magento\PageCache\Model\Config $subject, $result): bool
4952
{
5053
if ($result) {
54+
5155
$disable = $this->_scopeConfig->getValue(
5256
'loginascustomer/general/disable_page_cache',
5357
\Magento\Store\Model\ScopeInterface::SCOPE_STORE

app/code/Magento/LoginAsCustomer/Ui/Customer/Component/Control/LoginAsCustomerButton.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
1212

1313
/**
14-
* Login as customer button
14+
* Login As Customer button UI component.
1515
*/
1616
class LoginAsCustomerButton extends GenericButton implements ButtonProviderInterface
1717
{
@@ -33,7 +33,7 @@ public function __construct(
3333
}
3434

3535
/**
36-
* @return array
36+
* @inheritdoc
3737
*/
3838
public function getButtonData(): array
3939
{
@@ -49,10 +49,13 @@ public function getButtonData(): array
4949
'sort_order' => 70,
5050
];
5151
}
52+
5253
return $data;
5354
}
5455

5556
/**
57+
* Get Login As Customer login url.
58+
*
5659
* @return string
5760
*/
5861
public function getLoginUrl(): string

app/code/Magento/LoginAsCustomer/Ui/Store/Component/Control/LoginAsCustomerButton.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
1111

1212
/**
13-
* Class LoginAsCustomerButton
13+
* Login As Customer button UI component.
1414
*/
1515
class LoginAsCustomerButton implements ButtonProviderInterface
1616
{
@@ -32,4 +32,3 @@ public function getButtonData(): array
3232
];
3333
}
3434
}
35-

app/code/Magento/LoginAsCustomer/Ui/Store/DataProvider/Form/StoreDataProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Magento\Ui\DataProvider\AbstractDataProvider;
1212

1313
/**
14-
* Class StoreDataProvider
14+
* Login As Customer store view form data provider.
1515
*/
1616
class StoreDataProvider extends AbstractDataProvider
1717
{
@@ -34,5 +34,4 @@ public function __construct(
3434
$this->collection = $collectionFactory->create();
3535
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
3636
}
37-
3837
}

app/code/Magento/LoginAsCustomer/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
2424
<comment><![CDATA[If set to "Yes", when login as customer Page Cache will be disabled.]]></comment>
2525
</field>
26-
<field id="store_view_login" translate="label comment" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
26+
<field id="enable_store_view_manual_choice" translate="label comment" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
2727
<label>Store View To Login In</label>
2828
<source_model>Magento\LoginAsCustomer\Model\Config\Source\StoreViewLogin</source_model>
2929
<comment><![CDATA[

0 commit comments

Comments
 (0)