1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the TYPO3 CMS project. |
7
|
|
|
* |
8
|
|
|
* It is free software; you can redistribute it and/or modify it under |
9
|
|
|
* the terms of the GNU General Public License, either version 2 |
10
|
|
|
* of the License, or any later version. |
11
|
|
|
* |
12
|
|
|
* For the full copyright and license information, please read the |
13
|
|
|
* LICENSE.txt file that was distributed with this source code. |
14
|
|
|
* |
15
|
|
|
* The TYPO3 project - inspiring people to share! |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets; |
19
|
|
|
|
20
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Class AbstractFacetPackage |
24
|
|
|
*/ |
25
|
|
|
abstract class AbstractFacetPackage |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @return string |
29
|
|
|
*/ |
30
|
|
|
abstract public function getParserClassName(): string; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @return FacetParserInterface |
34
|
|
|
* @throws InvalidFacetPackageException |
35
|
|
|
*/ |
36
|
|
|
public function getParser(): FacetParserInterface |
37
|
|
|
{ |
38
|
|
|
$parser = GeneralUtility::makeInstance($this->getParserClassName()); |
39
|
|
|
if (!$parser instanceof FacetParserInterface) { |
40
|
|
|
throw new InvalidFacetPackageException('Invalid parser for package ' . __CLASS__); |
41
|
|
|
} |
42
|
|
|
return $parser; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
public function getUrlDecoderClassName(): string |
49
|
|
|
{ |
50
|
|
|
return DefaultUrlDecoder::class; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @throws InvalidUrlDecoderException |
55
|
|
|
* @return FacetUrlDecoderInterface |
56
|
|
|
*/ |
57
|
|
|
public function getUrlDecoder(): FacetUrlDecoderInterface |
58
|
|
|
{ |
59
|
|
|
$urlDecoder = GeneralUtility::makeInstance($this->getUrlDecoderClassName()); |
60
|
|
|
if (!$urlDecoder instanceof FacetUrlDecoderInterface) { |
61
|
|
|
throw new InvalidUrlDecoderException('Invalid url-decoder for package ' . __CLASS__); |
62
|
|
|
} |
63
|
|
|
return $urlDecoder; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return string |
68
|
|
|
*/ |
69
|
|
|
public function getQueryBuilderClassName(): string |
70
|
|
|
{ |
71
|
|
|
return DefaultFacetQueryBuilder::class; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @throws InvalidQueryBuilderException |
76
|
|
|
* @return FacetQueryBuilderInterface |
77
|
|
|
*/ |
78
|
|
|
public function getQueryBuilder(): FacetQueryBuilderInterface |
79
|
|
|
{ |
80
|
|
|
$urlDecoder = GeneralUtility::makeInstance($this->getQueryBuilderClassName()); |
81
|
|
|
if (!$urlDecoder instanceof FacetQueryBuilderInterface) { |
82
|
|
|
throw new InvalidQueryBuilderException('Invalid query-builder for package ' . __CLASS__); |
83
|
|
|
} |
84
|
|
|
return $urlDecoder; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|