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