Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Bohdan Berezhniy committed Aug 16, 2024
1 parent 34d3643 commit 6a1e157
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 78 deletions.
7 changes: 6 additions & 1 deletion Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Config
const XML_PATH_GENERAL_LIST_PAGE_CONTAINER_SELECTOR = 'mfproductlabel/general/pl_selector';

const XML_PATH_EXCLUDE_PAGE_TYPES = 'mfproductlabel/general/exclude_page_types';

/**
* Config constructor.
* @param ScopeConfigInterface $scopeConfig
Expand Down Expand Up @@ -89,9 +90,13 @@ public function getConfig($path, $storeId = null)
);
}

/**
* @return array
*/
public function getExcludePageTypes(): array
{
$pageTypes = $this->scopeConfig->getValue(self::XML_PATH_EXCLUDE_PAGE_TYPES);
$pageTypes = (string)$this->scopeConfig->getValue(self::XML_PATH_EXCLUDE_PAGE_TYPES);

return explode(',', $pageTypes);
}

Expand Down
71 changes: 0 additions & 71 deletions Model/Config/Backend/ExcludePageType.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ public function afterRenderResult(
ResponseInterface $response
) {
$html = $response->getBody();
if ($this->config->isEnabled() && (false !== strpos($html, Html::COMMENT_PREFIX))
&& !in_array($this->request->getFullActionName(),$this->config->getExcludePageTypes()))
{

if (
$this->config->isEnabled()
&& !in_array($this->request->getFullActionName(), $this->config->getExcludePageTypes())
&& (false !== strpos($html, Html::COMMENT_PREFIX))
) {
$response->setBody($this->htmlParser->execute($html));
}

Expand Down
6 changes: 3 additions & 3 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
<label>Product List Label Container</label>
<comment>Only one class that located above the product image!</comment>
</field>
<field id="exclude_page_types" translate="label" type="multiselect" sortOrder="20" showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
<label>Dont Use On Page</label>
<backend_model>Magefan\ProductLabel\Model\Config\Backend\ExcludePageType</backend_model>
<field id="exclude_page_types" translate="label" type="multiselect" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Don't Use On Pages</label>
<source_model>Magefan\ProductLabel\Model\Config\Source\PageType</source_model>
<can_be_empty>1</can_be_empty>
</field>
</group>
</section>
Expand Down
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<labels_per_product>1</labels_per_product>
<pp_selector>.fotorama__stage__shaft</pp_selector>
<pl_selector>.product-image-wrapper</pl_selector>
<exclude_page_types></exclude_page_types>
</general>
</mfproductlabel>

Expand Down

0 comments on commit 6a1e157

Please sign in to comment.