1 | <?php |
||
43 | class UsedFacetRenderer extends SimpleFacetOptionsRenderer |
||
44 | { |
||
45 | |||
46 | /** |
||
47 | * The name of the facet the filter is applied to. |
||
48 | * |
||
49 | * @var string |
||
50 | */ |
||
51 | protected $filter; |
||
52 | |||
53 | /** |
||
54 | * The filter value that has been applied to a query. |
||
55 | * |
||
56 | * @var string |
||
57 | */ |
||
58 | protected $filterValue; |
||
59 | |||
60 | /** |
||
61 | * Constructor |
||
62 | * |
||
63 | * @param string $facetName |
||
64 | * @param array $filterValue |
||
65 | * @param \ApacheSolrForTypo3\Solr\Template $filter |
||
66 | * @param \ApacheSolrForTypo3\Solr\Template $template |
||
67 | * @param \ApacheSolrForTypo3\Solr\Query $query |
||
68 | */ |
||
69 | 1 | public function __construct( |
|
70 | $facetName, |
||
71 | $filterValue, |
||
72 | $filter, |
||
73 | Template $template, |
||
74 | Query $query |
||
75 | ) { |
||
76 | 1 | parent::__construct($facetName, array(), $template, $query); |
|
77 | |||
78 | 1 | $this->filter = $filter; |
|
|
|||
79 | 1 | $this->filterValue = $filterValue; |
|
80 | 1 | } |
|
81 | |||
82 | /** |
||
83 | * Renders the block of used / applied facets. |
||
84 | * |
||
85 | * @return string Rendered HTML representing the used facet. |
||
86 | */ |
||
87 | 1 | public function render() |
|
88 | { |
||
89 | 1 | $solrConfiguration = Util::getSolrConfiguration(); |
|
90 | |||
91 | 1 | $facetOption = GeneralUtility::makeInstance(FacetOption::class, |
|
92 | 1 | $this->facetName, |
|
93 | 1 | $this->filterValue |
|
94 | ); |
||
95 | |||
96 | 1 | $facetLinkBuilder = GeneralUtility::makeInstance(LinkBuilder::class, |
|
97 | 1 | $this->query, |
|
98 | 1 | $this->facetName, |
|
99 | $facetOption |
||
100 | ); |
||
101 | /* @var $facetLinkBuilder LinkBuilder */ |
||
102 | 1 | $facetLinkBuilder->setLinkTargetPageId($this->linkTargetPageId); |
|
103 | |||
104 | 1 | if ($this->facetConfiguration['type'] == 'hierarchy') { |
|
105 | // FIXME decouple this |
||
106 | $filterEncoder = GeneralUtility::makeInstance(Hierarchy::class); |
||
107 | $facet = GeneralUtility::makeInstance(Facet::class, $this->facetName); |
||
108 | $facetRenderer = GeneralUtility::makeInstance(HierarchicalFacetRenderer::class, $facet); |
||
109 | |||
110 | $facetText = $facetRenderer->getLastPathSegmentFromHierarchicalFacetOption($filterEncoder->decodeFilter($this->filterValue)); |
||
111 | } else { |
||
112 | 1 | $facetText = $facetOption->render(); |
|
113 | } |
||
114 | |||
115 | 1 | $facetText = $this->getModifiedFacetTextFromHook($facetText); |
|
116 | |||
117 | 1 | $contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class); |
|
118 | 1 | $facetConfiguration = $solrConfiguration->getSearchFacetingFacetByName($this->facetName); |
|
119 | 1 | $facetLabel = $contentObject->stdWrap($facetConfiguration['label'], $facetConfiguration['label.']); |
|
120 | |||
121 | 1 | $removeFacetText = strtr( |
|
122 | 1 | $solrConfiguration->getSearchFacetingRemoveFacetLinkText(), |
|
123 | array( |
||
124 | 1 | '@facetValue' => $this->filterValue, |
|
125 | 1 | '@facetName' => $this->facetName, |
|
126 | 1 | '@facetLabel' => $facetLabel, |
|
127 | 1 | '@facetText' => $facetText |
|
128 | ) |
||
129 | ); |
||
130 | |||
131 | 1 | $removeFacetLink = $facetLinkBuilder->getRemoveFacetOptionLink($removeFacetText); |
|
132 | 1 | $removeFacetUrl = $facetLinkBuilder->getRemoveFacetOptionUrl(); |
|
133 | |||
134 | $facetToRemove = array( |
||
135 | 1 | 'link' => $removeFacetLink, |
|
136 | 1 | 'url' => $removeFacetUrl, |
|
137 | 1 | 'text' => $removeFacetText, |
|
138 | 1 | 'value' => $this->filterValue, |
|
139 | 1 | 'facet_name' => $this->facetName |
|
140 | ); |
||
141 | |||
142 | 1 | return $facetToRemove; |
|
143 | } |
||
144 | |||
145 | /** |
||
146 | * Provides a hook to overwrite the facetText. |
||
147 | * |
||
148 | * @param string $facetText |
||
149 | * @return mixed |
||
150 | */ |
||
151 | 1 | protected function getModifiedFacetTextFromHook($facetText) |
|
180 | } |
||
181 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..