|
1
|
|
|
<?php |
|
2
|
|
|
namespace ApacheSolrForTypo3\Solr\System\Configuration; |
|
3
|
|
|
|
|
4
|
|
|
/*************************************************************** |
|
5
|
|
|
* Copyright notice |
|
6
|
|
|
* |
|
7
|
|
|
* (c) 2017- Timo Schmidt <[email protected] |
|
8
|
|
|
* All rights reserved |
|
9
|
|
|
* |
|
10
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
|
11
|
|
|
* free software; you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU General Public License as published by |
|
13
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
14
|
|
|
* (at your option) any later version. |
|
15
|
|
|
* |
|
16
|
|
|
* The GNU General Public License can be found at |
|
17
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
|
18
|
|
|
* |
|
19
|
|
|
* This script is distributed in the hope that it will be useful, |
|
20
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
22
|
|
|
* GNU General Public License for more details. |
|
23
|
|
|
* |
|
24
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
|
25
|
|
|
***************************************************************/ |
|
26
|
|
|
|
|
27
|
|
|
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration as CoreExtensionConfiguration; |
|
28
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* This class encapsulates the access to the extension configuration. |
|
32
|
|
|
* |
|
33
|
|
|
* @author Timo Hund <[email protected]> |
|
34
|
|
|
*/ |
|
35
|
|
|
class ExtensionConfiguration implements UnifyConfigurationInterface |
|
36
|
|
|
{ |
|
37
|
|
|
/** |
|
38
|
|
|
* Extension Configuration |
|
39
|
|
|
* |
|
40
|
|
|
* @var array |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $configuration = []; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* ExtensionConfiguration constructor. |
|
46
|
|
|
* @param array $configurationToUse |
|
47
|
240 |
|
*/ |
|
48
|
|
|
public function __construct(array $configurationToUse = []) |
|
49
|
240 |
|
{ |
|
50
|
240 |
|
if (empty($configurationToUse)) { |
|
51
|
|
|
$this->configuration = GeneralUtility::makeInstance(CoreExtensionConfiguration::class)->get('solr'); |
|
52
|
6 |
|
} else { |
|
53
|
|
|
$this->configuration = $configurationToUse; |
|
54
|
240 |
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function load(): UnifyConfigurationInterface |
|
58
|
|
|
{ |
|
59
|
|
|
return $this; |
|
60
|
|
|
} |
|
61
|
141 |
|
|
|
62
|
|
|
/** |
|
63
|
141 |
|
* Get configuration for useConfigurationFromClosestTemplate |
|
64
|
|
|
* |
|
65
|
|
|
* @return bool |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getIsUseConfigurationFromClosestTemplateEnabled(): bool |
|
68
|
|
|
{ |
|
69
|
|
|
return (bool)$this->getConfigurationOrDefaultValue('useConfigurationFromClosestTemplate', false); |
|
70
|
|
|
} |
|
71
|
65 |
|
|
|
72
|
|
|
/** |
|
73
|
65 |
|
* Get configuration for useConfigurationTrackRecordsOutsideSiteroot |
|
74
|
|
|
* |
|
75
|
|
|
* @return bool |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getIsUseConfigurationTrackRecordsOutsideSiteroot(): bool |
|
78
|
|
|
{ |
|
79
|
|
|
return (bool)$this->getConfigurationOrDefaultValue('useConfigurationTrackRecordsOutsideSiteroot', true); |
|
80
|
|
|
} |
|
81
|
1 |
|
|
|
82
|
|
|
/** |
|
83
|
1 |
|
* Get configuration for allowSelfSignedCertificates |
|
84
|
|
|
* |
|
85
|
|
|
* @return bool |
|
86
|
|
|
*/ |
|
87
|
|
|
public function getIsSelfSignedCertificatesEnabled(): bool |
|
88
|
|
|
{ |
|
89
|
|
|
return (bool)$this->getConfigurationOrDefaultValue('allowSelfSignedCertificates', false); |
|
90
|
|
|
} |
|
91
|
43 |
|
|
|
92
|
|
|
/** |
|
93
|
43 |
|
* Get configuration for useConfigurationMonitorTables |
|
94
|
43 |
|
* |
|
95
|
|
|
* @return array of tableName |
|
96
|
43 |
|
*/ |
|
97
|
41 |
|
public function getIsUseConfigurationMonitorTables(): array |
|
98
|
|
|
{ |
|
99
|
|
|
$monitorTables = []; |
|
100
|
4 |
|
$monitorTablesList = $this->getConfigurationOrDefaultValue('useConfigurationMonitorTables', ''); |
|
101
|
|
|
|
|
102
|
|
|
if (empty($monitorTablesList)) { |
|
103
|
|
|
return $monitorTables; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
return GeneralUtility::trimExplode(',', $monitorTablesList); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Get configuration for allowLegacySiteMode |
|
111
|
|
|
* |
|
112
|
|
|
* @return bool |
|
113
|
|
|
* @deprecated |
|
114
|
|
|
*/ |
|
115
|
|
|
public function getIsAllowLegacySiteModeEnabled(): bool |
|
116
|
|
|
{ |
|
117
|
|
|
trigger_error('solr:deprecation: Method getIsAllowLegacySiteModeEnabled is deprecated since EXT:solr 11 and will be removed in 12. Since EXT:solr 10 legacy site handling is deprecated and was removed in EXT:solr 11.', E_USER_DEPRECATED); |
|
118
|
|
|
|
|
119
|
|
|
//@todo throw exception if set to true and log deprecation |
|
120
|
|
|
$legacyModeIsActive = $this->getConfigurationOrDefaultValue('allowLegacySiteMode', false); |
|
121
|
|
|
if($legacyModeIsActive === true) { |
|
122
|
|
|
throw new \InvalidArgumentException("Legacy mode is not supported anymore, please migrate your system to use sitehandling now!"); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
return false; |
|
126
|
150 |
|
} |
|
127
|
|
|
|
|
128
|
150 |
|
/** |
|
129
|
|
|
* @param string $key |
|
130
|
|
|
* @param mixed $defaultValue |
|
131
|
|
|
* @return mixed |
|
132
|
|
|
*/ |
|
133
|
|
|
protected function getConfigurationOrDefaultValue(string $key, $defaultValue) |
|
134
|
|
|
{ |
|
135
|
|
|
return isset($this->configuration[$key]) ? $this->configuration[$key] : $defaultValue; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* {@inheritDoc} |
|
140
|
|
|
*/ |
|
141
|
|
|
public function getUnifiedArray(): array |
|
142
|
|
|
{ |
|
143
|
|
|
// TODO: getIsUseConfigurationFromClosestTemplateEnabled needs implementation |
|
144
|
|
|
return [ |
|
145
|
|
|
'connection' => [ |
|
146
|
|
|
'read' => [ |
|
147
|
|
|
'allowSelfSignedCertificates' => $this->getIsSelfSignedCertificatesEnabled() |
|
148
|
|
|
], |
|
149
|
|
|
'write' => [ |
|
150
|
|
|
'allowSelfSignedCertificates' => $this->getIsSelfSignedCertificatesEnabled() |
|
151
|
|
|
] |
|
152
|
|
|
], |
|
153
|
|
|
'recordMonitor' => [ |
|
154
|
|
|
'trackOutsideRoot' => $this->getIsUseConfigurationTrackRecordsOutsideSiteroot(), |
|
155
|
|
|
'alwaysMonitorTables' => $this->getIsUseConfigurationMonitorTables() |
|
156
|
|
|
], |
|
157
|
|
|
]; |
|
158
|
|
|
} |
|
159
|
|
|
} |
|
160
|
|
|
|