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\Utility\GeneralUtility; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* This class encapsulates the access to the extension configuration. |
31
|
|
|
* |
32
|
|
|
* @author Timo Hund <[email protected]> |
33
|
|
|
*/ |
34
|
|
|
class ExtensionConfiguration |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* Extension Configuration |
38
|
|
|
* |
39
|
|
|
* @var array |
40
|
|
|
*/ |
41
|
|
|
protected $configuration = []; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* ExtensionConfiguration constructor. |
45
|
|
|
* @param array $configurationToUse |
46
|
|
|
*/ |
47
|
276 |
|
public function __construct($configurationToUse = []) |
48
|
|
|
{ |
49
|
276 |
|
if (empty($configurationToUse)) { |
50
|
276 |
|
$this->configuration = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get('solr'); |
51
|
|
|
} else { |
52
|
6 |
|
$this->configuration = $configurationToUse; |
53
|
|
|
} |
54
|
276 |
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Get configuration for useConfigurationFromClosestTemplate |
58
|
|
|
* |
59
|
|
|
* @return bool |
60
|
|
|
*/ |
61
|
176 |
|
public function getIsUseConfigurationFromClosestTemplateEnabled() |
62
|
|
|
{ |
63
|
176 |
|
return (bool)$this->getConfigurationOrDefaultValue('useConfigurationFromClosestTemplate', false); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Get configuration for useConfigurationTrackRecordsOutsideSiteroot |
68
|
|
|
* |
69
|
|
|
* @return bool |
70
|
|
|
*/ |
71
|
61 |
|
public function getIsUseConfigurationTrackRecordsOutsideSiteroot() |
72
|
|
|
{ |
73
|
61 |
|
return (bool)$this->getConfigurationOrDefaultValue('useConfigurationTrackRecordsOutsideSiteroot', true); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Get configuration for allowSelfSignedCertificates |
78
|
|
|
* |
79
|
|
|
* @return bool |
80
|
|
|
*/ |
81
|
1 |
|
public function getIsSelfSignedCertificatesEnabled() |
82
|
|
|
{ |
83
|
1 |
|
return (bool)$this->getConfigurationOrDefaultValue('allowSelfSignedCertificates', false); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Get configuration for useConfigurationMonitorTables |
88
|
|
|
* |
89
|
|
|
* @return array of tableName |
90
|
|
|
*/ |
91
|
40 |
|
public function getIsUseConfigurationMonitorTables() |
92
|
|
|
{ |
93
|
40 |
|
$monitorTables = []; |
94
|
40 |
|
$monitorTablesList = $this->getConfigurationOrDefaultValue('useConfigurationMonitorTables', ''); |
95
|
|
|
|
96
|
40 |
|
if (empty($monitorTablesList)) { |
97
|
38 |
|
return $monitorTables; |
98
|
|
|
} |
99
|
|
|
|
100
|
4 |
|
return GeneralUtility::trimExplode(',', $monitorTablesList); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Get configuration for allowLegacySiteMode |
105
|
|
|
* |
106
|
|
|
* @return bool |
107
|
|
|
*/ |
108
|
|
|
public function getIsAllowLegacySiteModeEnabled(): bool |
109
|
|
|
{ |
110
|
|
|
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); |
111
|
|
|
|
112
|
|
|
//@todo throw exception if set to true and log deprecation |
113
|
|
|
$legacyModeIsActive = $this->getConfigurationOrDefaultValue('allowLegacySiteMode', false); |
114
|
|
|
if($legacyModeIsActive === true) { |
115
|
|
|
throw new \InvalidArgumentException("Legacy mode is not supported anymore, please migrate your system to use sitehandling now!"); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
return false; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param string $key |
123
|
|
|
* @param mixed $defaultValue |
124
|
|
|
* @return mixed |
125
|
|
|
*/ |
126
|
185 |
|
protected function getConfigurationOrDefaultValue($key, $defaultValue) |
127
|
|
|
{ |
128
|
185 |
|
return isset($this->configuration[$key]) ? $this->configuration[$key] : $defaultValue; |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|