Skip to content

Commit 6a1e157

Browse files
author
Bohdan Berezhniy
committed
refactoring
1 parent 34d3643 commit 6a1e157

File tree

5 files changed

+16
-78
lines changed

5 files changed

+16
-78
lines changed

Model/Config.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Config
3434
const XML_PATH_GENERAL_LIST_PAGE_CONTAINER_SELECTOR = 'mfproductlabel/general/pl_selector';
3535

3636
const XML_PATH_EXCLUDE_PAGE_TYPES = 'mfproductlabel/general/exclude_page_types';
37+
3738
/**
3839
* Config constructor.
3940
* @param ScopeConfigInterface $scopeConfig
@@ -89,9 +90,13 @@ public function getConfig($path, $storeId = null)
8990
);
9091
}
9192

93+
/**
94+
* @return array
95+
*/
9296
public function getExcludePageTypes(): array
9397
{
94-
$pageTypes = $this->scopeConfig->getValue(self::XML_PATH_EXCLUDE_PAGE_TYPES);
98+
$pageTypes = (string)$this->scopeConfig->getValue(self::XML_PATH_EXCLUDE_PAGE_TYPES);
99+
95100
return explode(',', $pageTypes);
96101
}
97102

Model/Config/Backend/ExcludePageType.php

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

Plugin/Frontend/Magento/Framework/Controller/ResultInterface.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ public function afterRenderResult(
5757
ResponseInterface $response
5858
) {
5959
$html = $response->getBody();
60-
if ($this->config->isEnabled() && (false !== strpos($html, Html::COMMENT_PREFIX))
61-
&& !in_array($this->request->getFullActionName(),$this->config->getExcludePageTypes()))
62-
{
60+
61+
if (
62+
$this->config->isEnabled()
63+
&& !in_array($this->request->getFullActionName(), $this->config->getExcludePageTypes())
64+
&& (false !== strpos($html, Html::COMMENT_PREFIX))
65+
) {
6366
$response->setBody($this->htmlParser->execute($html));
6467
}
6568

etc/adminhtml/system.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
<label>Product List Label Container</label>
3636
<comment>Only one class that located above the product image!</comment>
3737
</field>
38-
<field id="exclude_page_types" translate="label" type="multiselect" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
39-
<label>Dont Use On Page</label>
40-
<backend_model>Magefan\ProductLabel\Model\Config\Backend\ExcludePageType</backend_model>
38+
<field id="exclude_page_types" translate="label" type="multiselect" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
39+
<label>Don't Use On Pages</label>
4140
<source_model>Magefan\ProductLabel\Model\Config\Source\PageType</source_model>
41+
<can_be_empty>1</can_be_empty>
4242
</field>
4343
</group>
4444
</section>

etc/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<labels_per_product>1</labels_per_product>
1717
<pp_selector>.fotorama__stage__shaft</pp_selector>
1818
<pl_selector>.product-image-wrapper</pl_selector>
19+
<exclude_page_types></exclude_page_types>
1920
</general>
2021
</mfproductlabel>
2122

0 commit comments

Comments
 (0)