76. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2020-08-14 00:01:32 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

76.1 Files compared

#LocationFileLast Modified
1Porto v3.2.3/Magento 2.x/Porto Theme/app/code/Mageplaza/LayeredNavigation/Model/LayerFilter.php2018-10-10 20:33:20 +0000
2Porto v3.2.4/Magento 2.x/Porto Theme/app/code/Mageplaza/LayeredNavigation/Model/LayerFilter.php2020-06-26 11:11:14 +0000

76.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged30336
Changed2050
Inserted89
Removed13

76.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

76.4 Active regular expressions

No regular expressions were active.

76.5 Comparison detail

1 <?php 1 <?php
2 /** 2 /**
3  * Mageplaza 3  * Mageplaza
4  * 4  *
5  * NOTICE OF LICENSE 5  * NOTICE OF LICENSE
6  * 6  *
7  * This source file is subject to the Mageplaza.com license that is 7  * This source file is subject to the Mageplaza.com license that is
8  * available through the world-wide-web at this URL: 8  * available through the world-wide-web at this URL:
9  * https://www.mageplaza.com/LICENSE.txt 9  * https://www.mageplaza.com/LICENSE.txt
10  * 10  *
11  * DISCLAIMER 11  * DISCLAIMER
12  * 12  *
13  * Do not edit or add to this file if you wish to upgrade this extension to newer 13  * Do not edit or add to this file if you wish to upgrade this extension to newer
14  * version in the future. 14  * version in the future.
15  * 15  *
16  * @category    Mageplaza 16  * @category    Mageplaza
17  * @package     Mageplaza_LayeredNavigation 17  * @package     Mageplaza_LayeredNavigation
18  * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/) 18  * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/)
19  * @license     https://www.mageplaza.com/LICENSE.txt 19  * @license     https://www.mageplaza.com/LICENSE.txt
20  */ 20  */
21  21 
22 namespace Mageplaza\LayeredNavigation\Model\Layer; 22 namespace Mageplaza\LayeredNavigation\Model\Layer;
23  23 
    24 use Magento\Catalog\Model\Layer\Filter\AbstractFilter;
    25 use Magento\Catalog\Model\Layer\Filter\Item;
24 use Magento\Framework\App\RequestInterface; 26 use Magento\Framework\App\RequestInterface;
    27 use Magento\Framework\Exception\LocalizedException;
25 use Mageplaza\LayeredNavigation\Helper\Data as LayerHelper; 28 use Mageplaza\LayeredNavigation\Helper\Data as LayerHelper;
26  29 
27 /** 30 /**
28  * Class Filter 31  * Class Filter
29  * @package Mageplaza\LayeredNavigation\Model\Layer 32  * @package Mageplaza\LayeredNavigation\Model\Layer
30  */ 33  */
31 class Filter 34 class Filter
32 { 35 {
33     /** @var \Magento\Framework\App\RequestInterface */ 36     /** @var 
RequestInterface */
34     protected $request; 37     protected $request;
35  38 
36     /** @var array Slider types */ 39     /** @var array Slider types */
37     protected $sliderTypes = [LayerHelper::FILTER_TYPE_SLIDER]; 40     protected $sliderTypes = [LayerHelper::FILTER_TYPE_SLIDER];
38  41 
39     /** 42     /**
40      * Filter constructor. 43      * Filter constructor.
41      * @param \Magento\Framework\App\RequestInterface $request 44      *
    45      * @param 
RequestInterface $request
42      */ 46      */
43     public function __construct(RequestInterface $request) 47     public function __construct(RequestInterface $request)
44     { 48     {
45         $this->request = $request; 49         $this->request = $request;
46     } 50     }
47  51 
48     /** 52     /**
49      * Layered configuration for js widget 53      * Layered configuration for js widget
50      * 54      *
51      * @param \Magento\Catalog\Model\Layer\Filter\AbstractFilter $filters 55      * @param 
AbstractFilter $filters
52      * @param $config 56      * @param $config
    57      *
53      * @return mixed 58      * @return mixed
54      */ 59      */
55     public function getLayerConfiguration($filters, $config) 60     public function getLayerConfiguration($filters, $config)
56     { 61     {
57         $slider = []; 62         $slider = [];
58         foreach ($filters as $filter) { 63         foreach ($filters as $filter) {
59             if ($this->getIsSliderTypes($filter) && $filter->getItemsCount()) { 64             if ($this->isSliderTypes($filter) && $filter->getItemsCount()) {
60                 $slider[$filter->getRequestVar()] = $filter->getSliderConfig(); 65                 $slider[$filter->getRequestVar()] = $filter->getSliderConfig();
61             } 66             }
62         } 67         }
63         $config->setData('slider', $slider); 68         $config->setData('slider', $slider);
64  69 
65         return $this; 70         return $this;
66     } 71     }
67  72 
68     /** 73     /**
69      * @param $filter 74      * @param $filter
70      * @param null $types 75      * @param null $types
    76      *
71      * @return bool 77      * @return bool
72      */ 78      */
73     public function getIsSliderTypes($filter, $types = null) 79     public function isSliderTypes($filter, $types = null)
74     { 80     {
75         $filterType = $this->getFilterType($filter); 81         $filterType = $this->getFilterType($filter);
76         $types      = $types ?: $this->sliderTypes; 82         $types      = $types ?: $this->sliderTypes;
77  83 
78         return in_array($filterType, $types
);
 84         return in_array($filterType, $types, true);
79     } 85     }
80  86 
81     /** 87     /**
82      * @param \Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter 88      * @param 
AbstractFilter $filter
83      * @param null $compareType 89      * @param null $compareType
    90      *
84      * @return bool|string 91      * @return bool|string
85      */ 92      */
86     public function getFilterType($filter, $compareType = null) 93     public function getFilterType($filter, $compareType = null)
87     { 94     {
88         $type = LayerHelper::FILTER_TYPE_LIST; 95         $type = LayerHelper::FILTER_TYPE_LIST;
89         if ($filter->getRequestVar() ==
 'price') {
 96         if ($filter->getRequestVar() === 'price') {
90             $type = LayerHelper::FILTER_TYPE_SLIDER; 97             $type = LayerHelper::FILTER_TYPE_SLIDER;
91         } 98         }
92  99 
93         return $compareType ? ($type ==
 $compareType) : $type;
 100         return $compareType ? ($type === $compareType) : $type;
94     } 101     }
95  102 
96     /** 103     /**
97      * Get option url. If it has been filtered, return removed url. Else return filter url 104      * Get option url. If it has been filtered, return removed url. Else return filter url
98      * 105      *
99      * @param \Magento\Catalog\Model\Layer\Filter\Item $item 106      * @param 
Item $item
    107      *
100      * @return mixed 108      * @return mixed
101      */ 109      */
102     public function getItemUrl($item) 110     public function getItemUrl($item)
103     { 111     {
104         if ($this->isSelected($item)) { 112         if ($this->isSelected($item)) {
105             return $item->getRemoveUrl(); 113             return $item->getRemoveUrl();
106         } 114         }
107  115 
108         return $item->getUrl(); 116         return $item->getUrl();
109     } 117     }
110  118 
111     /** 119     /**
112      * Check if option is selected or not 120      * Check if option is selected or not
113      * 121      *
114      * @param 
$item
 122      * @param Item $item
    123      *
115      * @return bool 124      * @return bool
    125      * @throws LocalizedException
116      */ 126      */
117     public function isSelected(
$item)
 127     public function isSelected(Item $item)
118     { 128     {
119         $filterValue = $this->getFilterValue($item->getFilter()); 129         $filterValue = $this->getFilterValue($item->getFilter());
120         if (!empty($filterValue) && in_array($item->getValue(), $filterValue)) {    
121             return true;    
122         }    
123  130 
124         return false; 131         return !empty($filterValue) && in_array((string) $item->getValue(), $filterValue, true);
125     } 132     }
126  133 
127     /** 134     /**
128      * @param \Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter 135      * @param 
AbstractFilter $filter
129      * @param bool|true $explode 136      * @param bool|true $explode
    137      *
130      * @return array|mixed 138      * @return array|mixed
131      */ 139      */
132     public function getFilterValue($filter, $explode = true) 140     public function getFilterValue($filter, $explode = true)
133     { 141     {
134         $filterValue = $this->request->getParam($filter->getRequestVar()); 142         $filterValue = $this->request->getParam($filter->getRequestVar());
135         if (empty($filterValue)) { 143         if (empty($filterValue)) {
136             return []; 144             return [];
137         } 145         }
138  146 
139         return $explode ? explode(',', $filterValue) : 
$filterValue
;
 147         return $explode ? explode(',', $filterValue) : [$filterValue];
140     } 148     }
141  149 
142     /** 150     /**
143      * Allow to show counter after options 151      * Allow to show counter after options
144      * 152      *
145      * @param \Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter 153      * @param 
AbstractFilter $filter
    154      *
146      * @return bool 155      * @return bool
147      */ 156      */
148     public function isShowCounter($filter) 157     public function isShowCounter($filter)
149     { 158     {
150         return true; 159         return true;
151     } 160     }
152  161 
153     /** 162     /**
154      * Allow multiple filter 163      * Allow multiple filter
155      * 164      *
156      * @param \Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter 165      * @param 
AbstractFilter $filter
    166      *
157      * @return bool 167      * @return bool
158      */ 168      */
159     public function isMultiple($filter) 169     public function isMultiple($filter)
160     { 170     {
161         if 
($this->getIsSliderTypes($filter) || $filter->getRequestVar() ==
 'price') {
 171         return !($this->isSliderTypes($filter) || $filter->getRequestVar() === 'price');
162             return false;    
163         }    
164     
165         return true;    
166     } 172     }
167  173 
168     /** 174     /**
169      * Checks whether the option reduces the number of results 175      * Checks whether the option reduces the number of results
170      * 176      *
171      * @param \Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter 177      * @param 
AbstractFilter $filter
172      * @param int $optionCount Count of search results with this option 178      * @param int $optionCount Count of search results with this option
173      * @param int $totalSize Current search results count 179      * @param int $totalSize Current search results count
    180      *
174      * @return bool 181      * @return bool
175      */ 182      */
176     public function isOptionReducesResults($filter, $optionCount, $totalSize) 183     public function isOptionReducesResults($filter, $optionCount, $totalSize)
177     { 184     {
178         $result = $optionCount <= $totalSize; 185         $result = $optionCount <= $totalSize;
179  186 
180         if ($this->isShowZero($filter)) { 187         if ($this->isShowZero($filter)) {
181             return $result; 188             return $result;
182         } 189         }
183  190 
184         return $optionCount && $result; 191         return $optionCount && $result;
185     } 192     }
186  193 
187     /** 194     /**
188      * @param \Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter 195      * @param 
AbstractFilter $filter
    196      *
189      * @return bool 197      * @return bool
190      */ 198      */
191     public function isShowZero($filter) 199     public function isShowZero($filter)
192     { 200     {
193         return false; 201         return false;
194     } 202     }
195 } 203 }