|
1
|
|
|
<?php |
|
2
|
|
|
namespace ApacheSolrForTypo3\Solr\System\Configuration; |
|
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
|
|
|
|
|
17
|
|
|
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException; |
|
18
|
|
|
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException; |
|
19
|
|
|
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration as CoreExtensionConfiguration; |
|
20
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* This class encapsulates the access to the extension configuration. |
|
24
|
|
|
* |
|
25
|
|
|
* @author Timo Hund <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
class ExtensionConfiguration |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* Extension Configuration |
|
31
|
|
|
* |
|
32
|
|
|
* @var array |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $configuration = []; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* ExtensionConfiguration constructor. |
|
38
|
|
|
* |
|
39
|
|
|
* @param array $configurationToUse |
|
40
|
|
|
* @throws ExtensionConfigurationExtensionNotConfiguredException |
|
41
|
|
|
* @throws ExtensionConfigurationPathDoesNotExistException |
|
42
|
|
|
*/ |
|
43
|
|
|
public function __construct(array $configurationToUse = []) |
|
44
|
|
|
{ |
|
45
|
|
|
if (empty($configurationToUse)) { |
|
46
|
|
|
$this->configuration = GeneralUtility::makeInstance(CoreExtensionConfiguration::class)->get('solr'); |
|
47
|
268 |
|
} else { |
|
48
|
|
|
$this->configuration = $configurationToUse; |
|
49
|
268 |
|
} |
|
50
|
268 |
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Get configuration for useConfigurationFromClosestTemplate |
|
54
|
268 |
|
* |
|
55
|
|
|
* @return bool |
|
56
|
|
|
*/ |
|
57
|
|
|
public function getIsUseConfigurationFromClosestTemplateEnabled() |
|
58
|
|
|
{ |
|
59
|
|
|
return (bool)$this->getConfigurationOrDefaultValue('useConfigurationFromClosestTemplate', false); |
|
60
|
|
|
} |
|
61
|
180 |
|
|
|
62
|
|
|
/** |
|
63
|
180 |
|
* Get configuration for useConfigurationTrackRecordsOutsideSiteroot |
|
64
|
|
|
* |
|
65
|
|
|
* @return bool |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getIsUseConfigurationTrackRecordsOutsideSiteroot() |
|
68
|
|
|
{ |
|
69
|
|
|
return (bool)$this->getConfigurationOrDefaultValue('useConfigurationTrackRecordsOutsideSiteroot', true); |
|
70
|
|
|
} |
|
71
|
62 |
|
|
|
72
|
|
|
/** |
|
73
|
62 |
|
* Get configuration for allowSelfSignedCertificates |
|
74
|
|
|
* |
|
75
|
|
|
* @return bool |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getIsSelfSignedCertificatesEnabled() |
|
78
|
|
|
{ |
|
79
|
|
|
return (bool)$this->getConfigurationOrDefaultValue('allowSelfSignedCertificates', false); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Get configuration for useConfigurationMonitorTables |
|
84
|
|
|
* |
|
85
|
|
|
* @return array of table names |
|
86
|
|
|
*/ |
|
87
|
|
|
public function getIsUseConfigurationMonitorTables(): array |
|
88
|
|
|
{ |
|
89
|
|
|
$monitorTables = []; |
|
90
|
|
|
$monitorTablesList = $this->getConfigurationOrDefaultValue('useConfigurationMonitorTables', ''); |
|
91
|
40 |
|
|
|
92
|
|
|
if (empty($monitorTablesList)) { |
|
93
|
40 |
|
return $monitorTables; |
|
94
|
40 |
|
} |
|
95
|
|
|
|
|
96
|
40 |
|
return GeneralUtility::trimExplode(',', $monitorTablesList); |
|
97
|
38 |
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
2 |
|
* Returns a list of available/whitelisted EXT:solr plugin namespaces. |
|
101
|
|
|
* Builds from "pluginNamespaces" extension configuration setting. |
|
102
|
|
|
* |
|
103
|
|
|
* @return array |
|
104
|
|
|
*/ |
|
105
|
|
|
public function getAvailablePluginNamespaces(): array |
|
106
|
|
|
{ |
|
107
|
|
|
$pluginNamespacesList = 'tx_solr,' . $this->getConfigurationOrDefaultValue( |
|
108
|
|
|
'pluginNamespaces' |
|
109
|
|
|
); |
|
110
|
|
|
return array_unique(GeneralUtility::trimExplode(',', $pluginNamespacesList)); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* Returns a list of cacheHash-excludedParameters matching the EXT:solr plugin namespaces. |
|
115
|
|
|
* |
|
116
|
|
|
* Builds from "pluginNamespaces" and takes "includeGlobalQParameterInCacheHash" |
|
117
|
|
|
* extension configuration settings into account. |
|
118
|
|
|
* |
|
119
|
|
|
* @return array |
|
120
|
|
|
*/ |
|
121
|
|
|
public function getCacheHashExcludedParameters(): array |
|
122
|
|
|
{ |
|
123
|
|
|
$pluginNamespaces = array_map( |
|
124
|
|
|
function ($pluginNamespace) { |
|
125
|
|
|
return '^' . $pluginNamespace . '['; |
|
126
|
182 |
|
}, |
|
127
|
|
|
$this->getAvailablePluginNamespaces() |
|
128
|
182 |
|
); |
|
129
|
|
|
if (false === $this->getIncludeGlobalQParameterInCacheHash()) { |
|
130
|
|
|
$pluginNamespaces[] = 'q'; |
|
131
|
|
|
} |
|
132
|
|
|
return array_combine($pluginNamespaces, $pluginNamespaces); |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* Returns the "includeGlobalQParameterInCacheHash" extension configuration setting. |
|
137
|
|
|
* |
|
138
|
|
|
* @return bool |
|
139
|
|
|
*/ |
|
140
|
|
|
public function getIncludeGlobalQParameterInCacheHash(): bool |
|
141
|
|
|
{ |
|
142
|
|
|
return (bool)$this->getConfigurationOrDefaultValue('includeGlobalQParameterInCacheHash', false); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* @param string $key |
|
147
|
|
|
* @param mixed $defaultValue |
|
148
|
|
|
* @return mixed|null |
|
149
|
|
|
*/ |
|
150
|
|
|
protected function getConfigurationOrDefaultValue(string $key, $defaultValue = null) |
|
151
|
|
|
{ |
|
152
|
|
|
return $this->configuration[$key] ?? $defaultValue; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
|
|
156
|
|
|
} |
|
157
|
|
|
|