1 | <?php |
||
39 | abstract class AbstractFacetRenderer implements FacetRenderer |
||
40 | { |
||
41 | |||
42 | /** |
||
43 | * @var Search |
||
44 | */ |
||
45 | protected $search; |
||
46 | |||
47 | /** |
||
48 | * The name of the facet being rendered |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $facetName; |
||
53 | |||
54 | /** |
||
55 | * The facet to render. |
||
56 | * |
||
57 | * @var Facet |
||
58 | */ |
||
59 | protected $facet; |
||
60 | |||
61 | /** |
||
62 | * @var array |
||
63 | */ |
||
64 | protected $facetConfiguration; |
||
65 | |||
66 | /** |
||
67 | * @var array |
||
68 | */ |
||
69 | protected $solrConfiguration; |
||
70 | |||
71 | /** |
||
72 | * Template |
||
73 | * |
||
74 | * @var Template |
||
75 | */ |
||
76 | protected $template = null; |
||
77 | |||
78 | /** |
||
79 | * Link target page id. |
||
80 | * |
||
81 | * @var int |
||
82 | */ |
||
83 | protected $linkTargetPageId = 0; |
||
84 | |||
85 | /** |
||
86 | * Query link builder |
||
87 | * |
||
88 | * @var LinkBuilder |
||
89 | */ |
||
90 | protected $queryLinkBuilder; |
||
91 | |||
92 | /** |
||
93 | * Constructor. |
||
94 | * |
||
95 | * @param Facet $facet The facet to render. |
||
96 | */ |
||
97 | 18 | public function __construct(Facet $facet) |
|
98 | { |
||
99 | 18 | $this->search = GeneralUtility::makeInstance(Search::class); |
|
100 | |||
101 | 18 | $this->facet = $facet; |
|
102 | 18 | $this->facetName = $facet->getName(); |
|
103 | |||
104 | 18 | $this->solrConfiguration = Util::getSolrConfiguration(); |
|
105 | 18 | $this->facetConfiguration = $this->solrConfiguration->getSearchFacetingFacetByName($this->facetName); |
|
106 | |||
107 | 18 | $this->linkTargetPageId = $GLOBALS['TSFE']->id; |
|
108 | |||
109 | 18 | $this->queryLinkBuilder = GeneralUtility::makeInstance(LinkBuilder::class, $this->search->getQuery()); |
|
110 | 18 | } |
|
111 | |||
112 | /** |
||
113 | * Renders the complete facet. |
||
114 | * |
||
115 | * @return string Facet markup. |
||
116 | */ |
||
117 | 18 | public function renderFacet() |
|
149 | |||
150 | /** |
||
151 | * Renders a numeric range facet by providing a slider |
||
152 | * |
||
153 | * @return string |
||
154 | */ |
||
155 | abstract protected function renderFacetOptions(); |
||
156 | |||
157 | /** |
||
158 | * (non-PHPdoc) |
||
159 | * @see \ApacheSolrForTypo3\Solr\Facet\FacetRenderer::getFacetProperties() |
||
160 | */ |
||
161 | 18 | public function getFacetProperties() |
|
186 | |||
187 | /** |
||
188 | * (non-PHPdoc) |
||
189 | * @see \ApacheSolrForTypo3\Solr\Facet\FacetRenderer::getFacetOptions() |
||
190 | */ |
||
191 | 18 | public function getFacetOptions() |
|
195 | |||
196 | /** |
||
197 | * (non-PHPdoc) |
||
198 | * @see \ApacheSolrForTypo3\Solr\Facet\FacetRenderer::getFacetOptionsCount() |
||
199 | */ |
||
200 | 18 | public function getFacetOptionsCount() |
|
204 | |||
205 | /** |
||
206 | * (non-PHPdoc) |
||
207 | * @see \ApacheSolrForTypo3\Solr\Facet\FacetRenderer::setTemplate() |
||
208 | * @param Template $template |
||
209 | */ |
||
210 | 18 | public function setTemplate(Template $template) |
|
214 | |||
215 | /** |
||
216 | * (non-PHPdoc) |
||
217 | * @see \ApacheSolrForTypo3\Solr\Facet\FacetRenderer::setLinkTargetPageId() |
||
218 | * @param int $linkTargetPageId |
||
219 | */ |
||
220 | 18 | public function setLinkTargetPageId($linkTargetPageId) |
|
225 | |||
226 | /** |
||
227 | * Builds the URL to reset all options of a facet - removing all its applied |
||
228 | * filters from a result set. |
||
229 | * |
||
230 | * @return string Url to remove a facet |
||
231 | */ |
||
232 | 18 | protected function buildResetFacetUrl() |
|
258 | } |
||
259 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: