File tree Expand file tree Collapse file tree 5 files changed +62
-10
lines changed
code/Magento/LayeredNavigation
design/frontend/Magento/luma/Magento_LayeredNavigation/templates/layer Expand file tree Collapse file tree 5 files changed +62
-10
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /************************************************************************
3+ *
4+ * Copyright 2024 Adobe
5+ * All Rights Reserved.
6+ *
7+ * NOTICE: All information contained herein is, and remains
8+ * the property of Adobe and its suppliers, if any. The intellectual
9+ * and technical concepts contained herein are proprietary to Adobe
10+ * and its suppliers and are protected by all applicable intellectual
11+ * property laws, including trade secret and copyright laws.
12+ * Dissemination of this information or reproduction of this material
13+ * is strictly forbidden unless prior written permission is obtained
14+ * from Adobe.
15+ * ************************************************************************
16+ */
17+
18+ namespace Magento \LayeredNavigation \ViewModel \Layer ;
19+
20+ use Magento \Framework \View \Element \Block \ArgumentInterface ;
21+ use Magento \LayeredNavigation \Block \Navigation \State as StateBlock ;
22+
23+ class State implements ArgumentInterface
24+ {
25+ /**
26+ * @param StateBlock $block
27+ */
28+ public function __construct (private StateBlock $ block )
29+ {
30+ }
31+
32+ /**
33+ * Skip string value '0' to be filtered against stripTags
34+ *
35+ * @param string $data
36+ * @return string
37+ */
38+ public function stripTags (string $ data ): string
39+ {
40+ if ($ data !== '0 ' ) {
41+ return $ this ->block ->stripTags ($ data );
42+ }
43+
44+ return $ data ;
45+ }
46+ }
Original file line number Diff line number Diff line change 1010 <attribute name =" class" value =" page-with-filter" />
1111 <referenceContainer name =" sidebar.main" >
1212 <block class =" Magento\LayeredNavigation\Block\Navigation\Category" name =" catalog.leftnav" before =" -" template =" Magento_LayeredNavigation::layer/view.phtml" >
13- <block class =" Magento\LayeredNavigation\Block\Navigation\State" name =" catalog.navigation.state" as =" state" />
13+ <block class =" Magento\LayeredNavigation\Block\Navigation\State" name =" catalog.navigation.state" as =" state" >
14+ <arguments >
15+ <argument name =" view_model" xsi : type =" object" >Magento\LayeredNavigation\ViewModel\Layer\State</argument >
16+ </arguments >
17+ </block >
1418 <block class =" Magento\LayeredNavigation\Block\Navigation\FilterRenderer" name =" catalog.navigation.renderer" as =" renderer" template =" Magento_LayeredNavigation::layer/filter.phtml" >
1519 <arguments >
1620 <argument name =" product_layer_view_model" xsi : type =" object" >Magento\LayeredNavigation\ViewModel\Layer\Filter</argument >
Original file line number Diff line number Diff line change 1010 <attribute name =" class" value =" page-with-filter" />
1111 <referenceContainer name =" sidebar.main" >
1212 <block class =" Magento\LayeredNavigation\Block\Navigation\Search" name =" catalogsearch.leftnav" before =" -" template =" Magento_LayeredNavigation::layer/view.phtml" >
13- <block class =" Magento\LayeredNavigation\Block\Navigation\State" name =" catalogsearch.navigation.state" as =" state" />
13+ <block class =" Magento\LayeredNavigation\Block\Navigation\State" name =" catalogsearch.navigation.state" as =" state" >
14+ <arguments >
15+ <argument name =" view_model" xsi : type =" object" >Magento\LayeredNavigation\ViewModel\Layer\State</argument >
16+ </arguments >
17+ </block >
1418 <block class =" Magento\LayeredNavigation\Block\Navigation\FilterRenderer" name =" catalogsearch.navigation.renderer" as =" renderer" template =" Magento_LayeredNavigation::layer/filter.phtml" >
1519 <arguments >
1620 <argument name =" product_layer_view_model" xsi : type =" object" >Magento\LayeredNavigation\ViewModel\Layer\Filter</argument >
Original file line number Diff line number Diff line change 1010 *
1111 * @var $escaper \Magento\Framework\Escaper
1212 * @var $block \Magento\LayeredNavigation\Block\Navigation\State
13+ * @var $viewModel \Magento\LayeredNavigation\ViewModel\Layer\State
1314 */
15+ $ viewModel = $ block ->getViewModel ();
1416?>
1517<?php $ _filters = $ block ->getActiveFilters () ?>
1618<?php if (!empty ($ _filters )): ?>
2426 <?php foreach ($ _filters as $ _filter ): ?>
2527 <li class="item">
2628 <span class="filter-label"><?= $ escaper ->escapeHtml (__ ($ _filter ->getName ())) ?> </span>
27- <span class="filter-value">
28- <?= ((string )$ _filter ->getLabel () === "0 " ) ? $ escaper ->escapeHtml ($ _filter ->getLabel ()) :
29- $ escaper ->escapeHtml ($ block ->stripTags ($ _filter ->getLabel ())) ?>
30- </span>
29+ <span class="filter-value"><?= $ escaper ->escapeHtml ($ viewModel ->stripTags ($ _filter ->getLabel ())) ?> </span>
3130 <?php
3231 $ clearLinkUrl = $ _filter ->getClearLinkUrl ();
3332 $ currentFilterName = $ escaper ->escapeHtmlAttr (
Original file line number Diff line number Diff line change 1212 *
1313 * @var $escaper \Magento\Framework\Escaper
1414 * @var $block \Magento\LayeredNavigation\Block\Navigation\State
15+ * @var $viewModel \Magento\LayeredNavigation\ViewModel\Layer\State
1516 */
17+ $ viewModel = $ block ->getViewModel ();
1618?>
1719<?php $ _filters = $ block ->getActiveFilters () ?>
1820<?php if (!empty ($ _filters )): ?>
2628 <?php foreach ($ _filters as $ _filter ): ?>
2729 <li class="item">
2830 <span class="filter-label"><?= $ escaper ->escapeHtml (__ ($ _filter ->getName ())) ?> </span>
29- <span class="filter-value">
30- <?= ((string )$ _filter ->getLabel () === "0 " ) ? $ escaper ->escapeHtml ($ _filter ->getLabel ()) :
31- $ escaper ->escapeHtml ($ block ->stripTags ($ _filter ->getLabel ())) ?>
32- </span>
31+ <span class="filter-value"><?= $ escaper ->escapeHtml ($ viewModel ->stripTags ($ _filter ->getLabel ())) ?> </span>
3332 <?php
3433 $ clearLinkUrl = $ _filter ->getClearLinkUrl ();
3534 $ currentFilterName = $ escaper ->escapeHtmlAttr (__ ($ _filter ->getName ()) . " " . $ block ->stripTags ($ _filter ->getLabel ()));
You can’t perform that action at this time.
0 commit comments