1414
1515namespace Smile \ElasticsuiteCatalog \Model \Layer ;
1616
17+ use Magento \Catalog \Model \Config \LayerCategoryConfig ;
18+ use Magento \Catalog \Model \Layer \FilterableAttributeListInterface ;
19+ use Magento \Framework \ObjectManagerInterface ;
20+ use Smile \ElasticsuiteCatalog \Api \Layer \Filter \TypeProviderInterface ;
21+
1722/**
1823 * FilterList customization to support decimal filters.
1924 *
@@ -28,6 +33,37 @@ class FilterList extends \Magento\Catalog\Model\Layer\FilterList
2833 */
2934 const BOOLEAN_FILTER = 'boolean ' ;
3035
36+ /**
37+ * @var TypeProviderInterface[]
38+ */
39+ private $ filterTypeProviders ;
40+
41+ /**
42+ * Constructor.
43+ *
44+ * @param ObjectManagerInterface $objectManager Object manager.
45+ * @param FilterableAttributeListInterface $filterableAttributes Filterable attributes list.
46+ * @param LayerCategoryConfig $layerCategoryConfig Category layer config.
47+ * @param array $filters Core filters array.
48+ * @param array $filterTypeProviders Injected custom type providers.
49+ */
50+ public function __construct (
51+ ObjectManagerInterface $ objectManager ,
52+ FilterableAttributeListInterface $ filterableAttributes ,
53+ LayerCategoryConfig $ layerCategoryConfig ,
54+ array $ filters = [],
55+ array $ filterTypeProviders = []
56+ ) {
57+ parent ::__construct (
58+ $ objectManager ,
59+ $ filterableAttributes ,
60+ $ layerCategoryConfig ,
61+ $ filters
62+ );
63+
64+ $ this ->filterTypeProviders = $ filterTypeProviders ;
65+ }
66+
3167 /**
3268 * {@inheritDoc}
3369 */
@@ -45,6 +81,13 @@ protected function getAttributeFilterClass(\Magento\Catalog\Model\ResourceModel\
4581 $ filterClassName = $ this ->filterTypes [self ::BOOLEAN_FILTER ];
4682 }
4783
84+ // Allow injected providers to override the filter class.
85+ foreach ($ this ->filterTypeProviders as $ provider ) {
86+ if ($ provider instanceof TypeProviderInterface) {
87+ $ filterClassName = $ provider ->getFilterClassName ($ attribute , $ filterClassName );
88+ }
89+ }
90+
4891 return $ filterClassName ;
4992 }
5093}
0 commit comments