Skip to content

Commit d143e5d

Browse files
committed
backward compatiblity, review changes
1 parent 91ba309 commit d143e5d

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

app/code/Magento/Developer/Model/TemplateEngine/Plugin/DebugHints.php

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class DebugHints
6565
*
6666
* @var string
6767
*/
68-
protected $debugHintsShowWithParameter;
68+
private $debugHintsWithParam;
6969

7070
/**
7171
* XPath of configuration of the debug hints URL parameter
@@ -74,7 +74,7 @@ class DebugHints
7474
*
7575
* @var string
7676
*/
77-
protected $debugHintsParameter;
77+
private $debugHintsParameter;
7878

7979
/**
8080
* @param ScopeConfigInterface $scopeConfig
@@ -83,7 +83,7 @@ class DebugHints
8383
* @param DebugHintsFactory $debugHintsFactory
8484
* @param string $debugHintsPath
8585
* @param Http $http
86-
* @param string $debugHintsShowWithParameter
86+
* @param string $debugHintsWithParam
8787
* @param string $debugHintsParameter
8888
*/
8989
public function __construct(
@@ -92,17 +92,19 @@ public function __construct(
9292
DevHelper $devHelper,
9393
DebugHintsFactory $debugHintsFactory,
9494
$debugHintsPath,
95-
Http $http,
96-
$debugHintsShowWithParameter,
97-
$debugHintsParameter
95+
Http $http = null,
96+
$debugHintsWithParam = null,
97+
$debugHintsParameter = null
9898
) {
9999
$this->scopeConfig = $scopeConfig;
100100
$this->storeManager = $storeManager;
101101
$this->devHelper = $devHelper;
102102
$this->debugHintsFactory = $debugHintsFactory;
103103
$this->debugHintsPath = $debugHintsPath;
104-
$this->http = $http;
105-
$this->debugHintsShowWithParameter = $debugHintsShowWithParameter;
104+
$this->http = $http ?: \Magento\Framework\App\ObjectManager::getInstance()->get(
105+
\Magento\Framework\App\Request\Http::class
106+
);
107+
$this->debugHintsWithParam = $debugHintsWithParam;
106108
$this->debugHintsParameter = $debugHintsParameter;
107109
}
108110

@@ -122,8 +124,8 @@ public function afterCreate(
122124
$storeCode = $this->storeManager->getStore()->getCode();
123125
if ($this->scopeConfig->getValue($this->debugHintsPath, ScopeInterface::SCOPE_STORE, $storeCode)
124126
&& $this->devHelper->isDevAllowed()) {
125-
$debugHintsShowWithParameter = $this->scopeConfig->getValue(
126-
$this->debugHintsShowWithParameter,
127+
$debugHintsWithParam = $this->scopeConfig->getValue(
128+
$this->debugHintsWithParam,
127129
ScopeInterface::SCOPE_STORE,
128130
$storeCode
129131
);
@@ -133,9 +135,16 @@ public function afterCreate(
133135
$storeCode
134136
);
135137
$debugHintsParameterInUrl = $this->http->getParam('templatehints');
136-
if ((!$debugHintsShowWithParameter) ||
137-
($debugHintsShowWithParameter &&
138-
$debugHintsParameter == $debugHintsParameterInUrl)) {
138+
139+
$showHints = false;
140+
if (!$debugHintsWithParam) {
141+
$showHints = true;
142+
}
143+
if ($debugHintsWithParam && $debugHintsParameter == $debugHintsParameterInUrl) {
144+
$showHints = true;
145+
}
146+
147+
if ($showHints) {
139148
$showBlockHints = $this->scopeConfig->getValue(
140149
self::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS,
141150
ScopeInterface::SCOPE_STORE,

app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Plugin/DebugHintsTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function setUp()
6363
public function testAfterCreateActive(
6464
$debugHintsPath,
6565
$showBlockHints,
66-
$debugHintsShowWithParameter,
66+
$debugHintsWithParam,
6767
$debugHintsParameter
6868
) {
6969
$this->devHelperMock->expects($this->once())
@@ -101,7 +101,7 @@ public function testAfterCreateActive(
101101
$this->debugHintsFactory,
102102
$debugHintsPath,
103103
$this->httpMock,
104-
$debugHintsShowWithParameter,
104+
$debugHintsWithParam,
105105
$debugHintsParameter
106106
);
107107

@@ -132,7 +132,7 @@ public function testAfterCreateInactive(
132132
$debugHintsPath,
133133
$isDevAllowed,
134134
$showTemplateHints,
135-
$debugHintsShowWithParameter,
135+
$debugHintsWithParam,
136136
$debugHintsParameter
137137
) {
138138
$this->devHelperMock->expects($this->any())
@@ -156,7 +156,7 @@ public function testAfterCreateInactive(
156156
$this->debugHintsFactory,
157157
$debugHintsPath,
158158
$this->httpMock,
159-
$debugHintsShowWithParameter,
159+
$debugHintsWithParam,
160160
$debugHintsParameter
161161
);
162162

app/code/Magento/Developer/etc/adminhtml/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<type name="Magento\Developer\Model\TemplateEngine\Plugin\DebugHints">
1313
<arguments>
1414
<argument name="debugHintsPath" xsi:type="string">dev/debug/template_hints_admin</argument>
15-
<argument name="debugHintsShowWithParameter" xsi:type="string">dev/debug/template_hints_storefront_show_with_parameter</argument>
15+
<argument name="debugHintsWithParam" xsi:type="string">dev/debug/template_hints_storefront_show_with_parameter</argument>
1616
<argument name="debugHintsParameter" xsi:type="string">dev/debug/template_hints_parameter_value</argument>
1717
</arguments>
1818
</type>

app/code/Magento/Developer/etc/frontend/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<type name="Magento\Developer\Model\TemplateEngine\Plugin\DebugHints">
1313
<arguments>
1414
<argument name="debugHintsPath" xsi:type="string">dev/debug/template_hints_storefront</argument>
15-
<argument name="debugHintsShowWithParameter" xsi:type="string">dev/debug/template_hints_storefront_show_with_parameter</argument>
15+
<argument name="debugHintsWithParam" xsi:type="string">dev/debug/template_hints_storefront_show_with_parameter</argument>
1616
<argument name="debugHintsParameter" xsi:type="string">dev/debug/template_hints_parameter_value</argument>
1717
</arguments>
1818
</type>

0 commit comments

Comments
 (0)