Failed Conditions
Push — master ( 5f60a5...9b80eb )
by Rafael
21:42
created

TypoScriptConfiguration   F

Complexity

Total Complexity 194

Size/Duplication

Total Lines 2309
Duplicated Lines 0 %

Test Coverage

Coverage 84.1%

Importance

Changes 0
Metric Value
wmc 194
dl 0
loc 2309
ccs 455
cts 541
cp 0.841
rs 0.6314
c 0
b 0
f 0

144 Methods

Rating   Name   Duplication   Size   Complexity  
A getSearchFacetingCountAllFacetsForSelection() 0 4 1
A getSearchVariantsField() 0 3 1
A getSearchFrequentSearchesMaxSize() 0 4 1
A setSearchQueryFilterConfiguration() 0 3 1
A getSearchVariantsLimit() 0 4 1
A getSearchQueryBigramPhraseFields() 0 3 1
A getSuggest() 0 4 1
B getEnabledIndexQueueConfigurationNames() 0 12 5
A getPhraseSearchIsEnabled() 0 4 1
A getViewHelpersCropConfiguration() 0 4 1
A getSearchFrequentSearchesMinSize() 0 4 1
A getLoggingIndexingIndexQueueInitialization() 0 4 1
A getLoggingIndexingQueue() 0 4 1
A getLoggingQueryRawPost() 0 4 1
A getSearchConfiguration() 0 4 1
A getBigramPhraseSearchIsEnabled() 0 4 1
A getSearchTargetPageConfiguration() 0 4 1
A getSearchShowResultsOfInitialQuery() 0 4 1
A getSearchQueryPhraseFields() 0 3 1
A getStatisticsAddDebugData() 0 4 1
A getLoggingExceptions() 0 4 1
A getSearchFrequentSearches() 0 4 1
A getSearchTargetPage() 0 9 2
A renderContentElementOfConfigured() 0 10 2
A getIndexQueueAdditionalPageIdsByConfigurationName() 0 9 2
A removeSearchQueryFilterForPageSections() 0 3 1
A getSearchFacetingFacetLinkUrlParametersAsArray() 0 8 2
A getStatistics() 0 4 1
A getSearchSortingFixedOrderBySortOptionName() 0 4 1
A getSearchGroupingResultLimit() 0 16 3
A getSearchQueryFilterConfiguration() 0 4 1
A getSearchFacetingFacetLinkUrlParametersUseForFacetResetLinkUrl() 0 4 1
A __construct() 0 5 2
A getSolrUsername() 0 5 1
A getSearchFacetingKeepAllFacetsOnSelection() 0 4 1
A getSearchKeepExistingParametersForNewSearches() 0 4 1
A getIndexQueueInitializerClassByConfigurationName() 0 6 1
A getIndexQueueIndexerConfigurationByConfigurationName() 0 5 1
A getObjectByPath() 0 12 3
A getIndexQueueAllowedPageTypesArrayByConfigurationName() 0 9 2
C getIndexQueueConfigurationNamesByTableName() 0 22 8
A getIndexQueueIndexerByConfigurationName() 0 5 1
A getStatisticsAnonymizeIP() 0 4 1
A getSearchFacetingFacetByName() 0 3 1
A mergeSolrConfiguration() 0 14 1
A getSearchFacetingFacetLimit() 0 3 1
A getIndexQueuePagesExcludeContentByClassArray() 0 10 2
A getSearchLastSearchesLimit() 0 4 1
A getSearchSortingOptionsConfiguration() 0 4 1
A getLoggingQuerySearchWords() 0 4 1
A getSearchSpellcheckingNumberOfSuggestionsToTry() 0 3 1
A getSearchFacetingLimit() 0 3 1
A getSearchResultsPerPage() 0 3 1
A getSearchTrustedFieldsArray() 0 9 2
A getEnableCommits() 0 4 1
A getSearchResultsPerPageSwitchOptionsAsArray() 0 9 2
A getSuggestNumberOfTopResults() 0 4 1
A getLoggingQueryRawDelete() 0 4 1
A getSearchSortingDefaultOrderBySortOptionName() 0 14 2
A getSearchGroupingNumberOfGroups() 0 3 1
A getSearchIgnoreGlobalQParameter() 0 4 1
A getSearchQueryReturnFieldsAsArray() 0 8 2
A getIndexAdditionalFieldsConfiguration() 0 4 1
A getSearchFacetingShowAllLinkWrap() 0 3 1
A getSearchPluginNamespace() 0 3 1
A getLoggingIndexingQueueOperationsByConfigurationNameWithFallBack() 0 15 3
A getIndexMappedAdditionalFieldNames() 0 5 2
A getSearchElevation() 0 4 1
A getEnabled() 0 5 1
A getIndexQueueFieldsConfigurationByConfigurationName() 0 5 1
A getSolrPassword() 0 5 1
A getSolrHasConnectionConfiguration() 0 4 2
A getBool() 0 3 1
A getSearchSpellcheckingWrap() 0 3 1
A getIndexQueueIsMonitoredTable() 0 3 1
A getSolrScheme() 0 5 1
A getSolrPath() 0 10 1
A getSearchGroupingGroupsConfiguration() 0 3 1
A getSearchSpellchecking() 0 4 1
A getSearchFrequentSearchesUseLowercaseKeywords() 0 4 1
A getSearchFacetingFacetLinkUrlParameters() 0 5 1
A getIndexQueueConfigurationRecursiveUpdateFields() 0 10 2
A getSolrPort() 0 5 1
A getIndexFieldProcessingInstructionsConfiguration() 0 4 1
A getSearchSorting() 0 4 1
A getAvailableTemplatesByFileKey() 0 4 1
A getOnlyArrayKeysWhereValueIsNotAnArray() 0 14 3
A getIndexQueueConfigurationByName() 0 5 1
A getLoggingIndexing() 0 4 1
A getLocalLangConfiguration() 0 4 1
A getViewHelpersSortIndicatorConfiguration() 0 4 1
A getSearchVariants() 0 4 1
A getSuggestNumberOfSuggestions() 0 4 1
A getSearchShowResultsOfInitialEmptyQuery() 0 4 1
A getSuggestForceHttps() 0 4 1
A getSearchFacetingSortBy() 0 3 1
A getSearchResultsHighlightingFields() 0 3 1
A getSuggestShowTopResults() 0 4 1
A getLoggingQueryFilters() 0 4 1
A getTrigramPhraseSearchIsEnabled() 0 4 1
A getIndexQueueAdditionalWhereClauseByConfigurationName() 0 10 2
A getIndexQueueConfigurationIsEnabled() 0 5 1
A getSearchFacetingFacets() 0 3 1
A getSearchFacetingMinimumCount() 0 3 1
A getSearchInitializeWithEmptyQuery() 0 4 1
A getSearchElevationForceElevation() 0 4 1
A getSearchVariantsExpand() 0 4 1
A getSearchLastSearchesMode() 0 4 1
A getIndexQueueMonitoredTables() 0 15 3
A getSearchFrequentSearchesConfiguration() 0 4 1
A getSearchInitializeWithQuery() 0 4 1
A getIndexQueueMappedFieldsByConfigurationName() 0 5 2
A getSearchFacetingShowEmptyFacetsByName() 0 14 2
A getValueByPath() 0 7 2
A getSearchResultsHighlightingFieldsAsArray() 0 9 2
A getValueByPathOrDefaultValue() 0 8 2
A getSolrHost() 0 5 1
A getLoggingIndexingMissingTypo3SearchMarkers() 0 4 1
A getSearchSpellcheckingSearchUsingSpellCheckerSuggestion() 0 4 1
A getLoggingIndexingPageIndexed() 0 4 1
A getEnabledDebugMode() 0 4 1
A getObjectByPathOrDefault() 0 13 3
B getSearchGroupingHighestGroupResultsLimit() 0 20 6
A getLoggingQueryQueryString() 0 4 1
A getSearchResultsHighlightingFragmentSize() 0 3 1
A getViewTemplateByFileKey() 0 4 1
A getSolrTimeout() 0 3 1
A getSearchGrouping() 0 4 1
A getLoggingDebugOutput() 0 4 1
A getSearchQueryAllowEmptyQuery() 0 4 1
A getSearchResultsSiteHighlighting() 0 4 1
A getInitialPagesAdditionalWhereClause() 0 10 2
A getSearchElevationMarkElevatedResults() 0 4 1
A getSearchResultsHighlightingWrap() 0 3 1
A getIndexQueueTableNameOrFallbackToConfigurationName() 0 5 1
A getSearchResultsHighlightingFragmentSeparator() 0 3 1
A getSearchLastSearches() 0 4 1
A getSearchFacetingSingleFacetMode() 0 4 1
A getSearchResultsHighlighting() 0 4 1
A getSearchQueryTrigramPhraseFields() 0 3 1
A getLoggingQueryRawGet() 0 4 1
A getSearchQueryQueryFields() 0 3 1
A getSearchFaceting() 0 4 1
A isValidPath() 0 10 2

How to fix   Complexity   

Complex Class

Complex classes like TypoScriptConfiguration often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use TypoScriptConfiguration, and based on these observations, apply Extract Interface, too.

1
<?php
2
namespace ApacheSolrForTypo3\Solr\System\Configuration;
3
4
/***************************************************************
5
 *  Copyright notice
6
 *
7
 *  (c) 2016 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
 *  A copy is found in the textfile GPL.txt and important notices to the license
19
 *  from the author is found in LICENSE.txt distributed with these scripts.
20
 *
21
 *
22
 *  This script is distributed in the hope that it will be useful,
23
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 *  GNU General Public License for more details.
26
 *
27
 *  This copyright notice MUST APPEAR in all copies of the script!
28
 ***************************************************************/
29
30
use ApacheSolrForTypo3\Solr\IndexQueue\Indexer;
31
use ApacheSolrForTypo3\Solr\IndexQueue\Initializer\Record;
32
use ApacheSolrForTypo3\Solr\System\ContentObject\ContentObjectService;
33
use ApacheSolrForTypo3\Solr\System\Util\ArrayAccessor;
34
use InvalidArgumentException;
35
use TYPO3\CMS\Core\Utility\ArrayUtility;
36
use TYPO3\CMS\Core\Utility\GeneralUtility;
37
38
/**
39
 * TypoScript configuration object, used to read all TypoScript configuration.
40
 *
41
 * The TypoScriptConfiguration was introduced in order to be able to replace the old,
42
 * array based configuration with one configuration object.
43
 *
44
 * To read the configuration, you should use
45
 *
46
 * $configuration->getValueByPath
47
 *
48
 * or
49
 *
50
 * $configuration->isValidPath
51
 *
52
 * to check if an configuration path exists.
53
 *
54
 * To ensure Backwards compatibility the TypoScriptConfiguration object implements the
55
 * ArrayAccess interface (offsetGet,offsetExists,offsetUnset and offsetSet)
56
 *
57
 * This was only introduced to be backwards compatible in logTerm only "getValueByPath", "isValidPath" or
58
 * speaking methods for configuration settings should be used!
59
 *
60
 * @author Marc Bastian Heinrichs <[email protected]>
61
 * @author Timo Schmidt <[email protected]>
62
 */
63
class TypoScriptConfiguration
64
{
65
    /**
66
     * @var \ApacheSolrForTypo3\Solr\System\Util\ArrayAccessor|null
67
     */
68
    protected $configurationAccess = null;
69
70
    /**
71
     * Holds the pageId in which context the configuration was parsed
72
     * (normally $GLOBALS['TSFE']->id)
73
     */
74
    protected $contextPageId = 0;
75
76
    /**
77
     * @var ContentObjectService
78
     */
79
    protected $contentObjectService;
80
81
    /**
82
     * @param array $configuration
83
     * @param int $contextPageId
84
     * @param ContentObjectService $contentObjectService
85
     */
86 307
    public function __construct(array $configuration, $contextPageId = 0, ContentObjectService $contentObjectService = null)
87
    {
88 307
        $this->configurationAccess = new ArrayAccessor($configuration, '.', true);
89 307
        $this->contextPageId = $contextPageId;
90 307
        $this->contentObjectService = is_null($contentObjectService) ? GeneralUtility::makeInstance(ContentObjectService::class) : $contentObjectService;
91 307
    }
92
93
    /**
94
     * Checks if a value is 1, '1', 'true'
95
     * @param mixed $value
96
     * @return bool
97
     */
98 267
    protected function getBool($value)
99
    {
100 267
        return filter_var($value, FILTER_VALIDATE_BOOLEAN);
101
    }
102
103
    /**
104
     * This method can be used to only retrieve array keys where the value is not an array.
105
     *
106
     * This can be very handy in the configuration when only keys should ne taken into account
107
     * where the value is not a subconfiguration (typically an typoscript object path).
108
     *
109
     * @param $inputArray
110
     * @return array
111
     */
112 48
    protected function getOnlyArrayKeysWhereValueIsNotAnArray($inputArray)
113
    {
114 48
        $keysWithNonArrayValue = [];
115
116 48
        foreach ($inputArray as $key => $value) {
117 48
            if (is_array($value)) {
118
                // configuration for a content object, skipping
119 42
                continue;
120
            }
121
122 48
            $keysWithNonArrayValue[] = $key;
123
        }
124
125 48
        return $keysWithNonArrayValue;
126
    }
127
128
    /**
129
     * Gets the value from a given TypoScript path.
130
     *
131
     * In the context of an frontend content element the path plugin.tx_solr is
132
     * merged recursive with overrule with the content element specific typoscript
133
     * settings, like plugin.tx_solr_PiResults_Results, and possible flex form settings
134
     * (depends on the solr plugin).
135
     *
136
     * Example: plugin.tx_solr.search.targetPage
137
     * returns $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['search.']['targetPage']
138
     *
139
     * @param string $path TypoScript path
140
     * @return mixed The TypoScript object defined by the given path
141
     * @throws InvalidArgumentException
142
     */
143 311
    public function getValueByPath($path)
144
    {
145 311
        if (!is_string($path)) {
0 ignored issues
show
introduced by
The condition ! is_string($path) can never be true.
Loading history...
146
            throw new InvalidArgumentException('Parameter $path is not a string',
147
                1325623321);
148
        }
149 311
        return $this->configurationAccess->get($path);
0 ignored issues
show
Bug introduced by
The method get() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

149
        return $this->configurationAccess->/** @scrutinizer ignore-call */ get($path);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
150
    }
151
152
    /**
153
     * This method can be used to get  a configuration value by path if it exists or return a
154
     * default value when it does not exist.
155
     *
156
     * @param string $path
157
     * @param mixed $defaultValue
158
     * @return mixed
159
     */
160 308
    public function getValueByPathOrDefaultValue($path, $defaultValue)
161
    {
162 308
        $value = $this->getValueByPath($path);
163 308
        if (is_null($value)) {
164 297
            return $defaultValue;
165
        }
166
167 182
        return $value;
168
    }
169
170
    /**
171
     * Gets the parent TypoScript Object from a given TypoScript path.
172
     *
173
     * In the context of an frontend content element the path plugin.tx_solr is
174
     * merged recursive with overrule with the content element specific typoscript
175
     * settings, like plugin.tx_solr_PiResults_Results, and possible flex form settings
176
     * (depends on the solr plugin).
177
     *
178
     * Example: plugin.tx_solr.index.queue.tt_news.fields.content
179
     * returns $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['index.']['queue.']['tt_news.']['fields.']['content.']
180
     * which is a SOLR_CONTENT cObj.
181
     *
182
     * @param string $path TypoScript path
183
     * @return array The TypoScript object defined by the given path
184
     * @throws InvalidArgumentException
185
     */
186 292
    public function getObjectByPath($path)
187
    {
188 292
        if (substr($path, -1) !== '.') {
189 1
            $path = rtrim($path, '.');
190 1
            $path = substr($path, 0, strrpos($path, '.') + 1);
191
        }
192
193 292
        if (!is_string($path)) {
0 ignored issues
show
introduced by
The condition ! is_string($path) can never be true.
Loading history...
194
            throw new InvalidArgumentException('Parameter $path is not a string', 1325627243);
195
        }
196
197 292
        return $this->configurationAccess->get($path);
198
    }
199
200
    /**
201
     * Gets the parent TypoScript Object from a given TypoScript path and if not present return
202
     * the default value
203
     *
204
     * @see getObjectByPath
205
     * @param string $path
206
     * @param array $defaultValue
207
     * @return array
208
     */
209 287
    public function getObjectByPathOrDefault($path, array $defaultValue)
210
    {
211
        try {
212 287
            $object = $this->getObjectByPath($path);
213
        } catch (\InvalidArgumentException $e) {
214
            return $defaultValue;
215
        }
216
217 287
        if (!is_array($object)) {
0 ignored issues
show
introduced by
The condition ! is_array($object) can never be true.
Loading history...
218 142
            return $defaultValue;
219
        }
220
221 202
        return $object;
222
    }
223
224
    /**
225
     * Checks whether a given TypoScript path is valid.
226
     *
227
     * @param string $path TypoScript path
228
     * @return bool TRUE if the path resolves, FALSE otherwise
229
     */
230
    public function isValidPath($path)
231
    {
232
        $isValidPath = false;
233
234
        $pathValue = $this->getValueByPath($path);
235
        if (!is_null($pathValue)) {
236
            $isValidPath = true;
237
        }
238
239
        return $isValidPath;
240
    }
241
242
    /**
243
     * Merges a configuration with another configuration a
244
     *
245
     * @param array $configurationToMerge
246
     * @param bool $addKeys If set to FALSE, keys that are NOT found in $original will not be set. Thus only existing value can/will be overruled from overrule array.
247
     * @param bool $includeEmptyValues If set, values from $overrule will overrule if they are empty or zero.
248
     * @param bool $enableUnsetFeature If set, special values "__UNSET" can be used in the overrule array in order to unset array keys in the original array.
249
     * @return TypoScriptConfiguration
250
     */
251 21
    public function mergeSolrConfiguration(array $configurationToMerge, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true)
252
    {
253 21
        $data = $this->configurationAccess->getData();
254 21
        ArrayUtility::mergeRecursiveWithOverrule(
255 21
            $data['plugin.']['tx_solr.'],
256 21
            $configurationToMerge,
257 21
            $addKeys,
258 21
            $includeEmptyValues,
259 21
            $enableUnsetFeature
260
        );
261
262 21
        $this->configurationAccess->setData($data);
263
264 21
        return $this;
265
    }
266
267
    /**
268
     * Returns true when ext_solr is enabled
269
     *
270
     * @param boolean $defaultIfEmpty
271
     * @return boolean
272
     */
273 3
    public function getEnabled($defaultIfEmpty = false)
274
    {
275 3
        $path = 'plugin.tx_solr.enabled';
276 3
        $result = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty);
277 3
        return $this->getBool($result);
278
    }
279
280
    /**
281
     * Returns the configured additionalFields configured for the indexing.
282
     *
283
     * plugin.tx_solr.index.additionalFields.
284
     *
285
     * @param array $defaultIfEmpty
286
     * @return array
287
     */
288 3
    public function getIndexAdditionalFieldsConfiguration($defaultIfEmpty = [])
289
    {
290 3
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.index.additionalFields.', $defaultIfEmpty);
291 3
        return $result;
292
    }
293
294
    /**
295
     * Returns all solr fields names where a mapping is configured in index.additionalFields
296
     *
297
     * Returns all keys from
298
     * plugin.tx_solr.index.additionalFields.
299
     *
300
     * @param array $defaultIfEmpty
301
     * @return array
302
     */
303 2
    public function getIndexMappedAdditionalFieldNames($defaultIfEmpty = [])
304
    {
305 2
        $mappingConfiguration = $this->getIndexAdditionalFieldsConfiguration();
306 2
        $mappedFieldNames = $this->getOnlyArrayKeysWhereValueIsNotAnArray($mappingConfiguration);
307 2
        return count($mappedFieldNames) == 0 ? $defaultIfEmpty : $mappedFieldNames;
308
    }
309
310
    /**
311
     * Returns the fieldProcessingInstructions configuration array
312
     *
313
     * plugin.tx_solr.index.fieldProcessingInstructions.
314
     *
315
     * @param array $defaultIfEmpty
316
     * @return array
317
     */
318 85
    public function getIndexFieldProcessingInstructionsConfiguration(array $defaultIfEmpty = [])
319
    {
320 85
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.index.fieldProcessingInstructions.', $defaultIfEmpty);
321 85
        return $result;
322
    }
323
324
    /**
325
     * Retrieves the indexing configuration array for an indexing queue by configuration name.
326
     *
327
     * plugin.tx_solr.index.queue.<configurationName>.
328
     *
329
     * @param string $configurationName
330
     * @param array $defaultIfEmpty
331
     * @return array
332
     */
333 6
    public function getIndexQueueConfigurationByName($configurationName, array $defaultIfEmpty = [])
334
    {
335 6
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.';
336 6
        $result = $this->getObjectByPathOrDefault($path, $defaultIfEmpty);
337 6
        return $result;
338
    }
339
340
    /**
341
     * Returns an array of all additionalPageIds by index configuration name.
342
     *
343
     * plugin.tx_solr.index.queue.pages.additionalPageIds
344
     *
345
     * @param string $configurationName
346
     * @param array $defaultIfEmpty
347
     * @return array
348
     */
349 42
    public function getIndexQueueAdditionalPageIdsByConfigurationName($configurationName = 'pages', $defaultIfEmpty = [])
350
    {
351 42
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.additionalPageIds';
352 42
        $result = $this->getValueByPathOrDefaultValue($path, '');
353 42
        if (trim($result) === '') {
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array; however, parameter $str of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

353
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
354 38
            return $defaultIfEmpty;
355
        }
356
357 4
        return GeneralUtility::trimExplode(',', $result);
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array; however, parameter $string of TYPO3\CMS\Core\Utility\G...lUtility::trimExplode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

357
        return GeneralUtility::trimExplode(',', /** @scrutinizer ignore-type */ $result);
Loading history...
358
    }
359
360
    /**
361
     * Returns an array of all allowedPageTypes.
362
     *
363
     * plugin.tx_solr.index.queue.pages.allowedPageTypes
364
     *
365
     * @param string $configurationName The configuration name of the queue to use.
366
     * @param array $defaultIfEmpty
367
     * @return array
368
     */
369 30
    public function getIndexQueueAllowedPageTypesArrayByConfigurationName($configurationName = 'pages', $defaultIfEmpty = [])
370
    {
371 30
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.allowedPageTypes';
372 30
        $result = $this->getValueByPathOrDefaultValue($path, '');
373 30
        if (trim($result) === '') {
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array; however, parameter $str of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

373
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
374
            return $defaultIfEmpty;
375
        }
376
377 30
        return GeneralUtility::trimExplode(',', $result);
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array; however, parameter $string of TYPO3\CMS\Core\Utility\G...lUtility::trimExplode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

377
        return GeneralUtility::trimExplode(',', /** @scrutinizer ignore-type */ $result);
Loading history...
378
    }
379
380
    /**
381
     * Returns the configured excludeContentByClass patterns as array.
382
     *
383
     * plugin.tx_solr.index.queue.pages.excludeContentByClass
384
     *
385
     * @param array $defaultIfEmpty
386
     * @return array
387
     */
388 50
    public function getIndexQueuePagesExcludeContentByClassArray($defaultIfEmpty = [])
389
    {
390 50
        $path = 'plugin.tx_solr.index.queue.pages.excludeContentByClass';
391 50
        $result = $this->getValueByPathOrDefaultValue($path, '');
392
393 50
        if (trim($result) === '') {
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array; however, parameter $str of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

393
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
394 7
            return $defaultIfEmpty;
395
        }
396
397 43
        return GeneralUtility::trimExplode(',', $result);
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array; however, parameter $string of TYPO3\CMS\Core\Utility\G...lUtility::trimExplode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

397
        return GeneralUtility::trimExplode(',', /** @scrutinizer ignore-type */ $result);
Loading history...
398
    }
399
400
    /**
401
     * Returns the configured database table for an indexing queue configuration or
402
     * the configurationName itself that is used by convention as tableName when no
403
     * other tablename is present.
404
     *
405
     * plugin.tx_solr.index.queue.<configurationName>.table or configurationName
406
     *
407
     * @param string $configurationName
408
     * @return string
409
     */
410 71
    public function getIndexQueueTableNameOrFallbackToConfigurationName($configurationName = '')
411
    {
412 71
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.table';
413 71
        $result = $this->getValueByPathOrDefaultValue($path, $configurationName);
414 71
        return $result;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $result also could return the type array which is incompatible with the documented return type string.
Loading history...
415
    }
416
417
    /**
418
     * Returns the field configuration for a specific index queue.
419
     *
420
     * plugin.tx_solr.index.queue.<configurationName>.fields.
421
     *
422
     * @param string $configurationName
423
     * @param array $defaultIfEmpty
424
     * @return array
425
     */
426 67
    public function getIndexQueueFieldsConfigurationByConfigurationName($configurationName = '', $defaultIfEmpty = [])
427
    {
428 67
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.fields.';
429 67
        $result = $this->getObjectByPathOrDefault($path, $defaultIfEmpty);
430 67
        return $result;
431
    }
432
433
    /**
434
     * Gets an array of tables configured for indexing by the Index Queue. Since the
435
     * record monitor must watch these tables for manipulation.
436
     *
437
     * @return array Array of table names to be watched by the record monitor.
438
     */
439 35
    public function getIndexQueueMonitoredTables()
440
    {
441 35
        $monitoredTables = [];
442
443 35
        $indexingConfigurations = $this->getEnabledIndexQueueConfigurationNames();
444 35
        foreach ($indexingConfigurations as $indexingConfigurationName) {
445 35
            $monitoredTable = $this->getIndexQueueTableNameOrFallbackToConfigurationName($indexingConfigurationName);
446 35
            $monitoredTables[] = $monitoredTable;
447 35
            if ($monitoredTable === 'pages') {
448
                // when monitoring pages, also monitor creation of translations
449 35
                $monitoredTables[] = 'pages_language_overlay';
450
            }
451
        }
452
453 35
        return array_values(array_unique($monitoredTables));
454
    }
455
456
    /**
457
     * This method can be used to check if a table is configured to be monitored by the record monitor.
458
     *
459
     * @param string $tableName
460
     * @return bool
461
     */
462 34
    public function getIndexQueueIsMonitoredTable($tableName)
463
    {
464 34
        return in_array($tableName, $this->getIndexQueueMonitoredTables(), true);
465
    }
466
467
    /**
468
     * Returns the configured indexer class that should be used for a certain indexingConfiguration.
469
     * By default "ApacheSolrForTypo3\Solr\IndexQueue\Indexer" will be returned.
470
     *
471
     * plugin.tx_solr.index.queue.<configurationName>.indexer
472
     *
473
     * @param string $configurationName
474
     * @param string $defaultIfEmpty
475
     * @return string
476
     */
477 6
    public function getIndexQueueIndexerByConfigurationName($configurationName, $defaultIfEmpty = Indexer::class)
478
    {
479 6
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.indexer';
480 6
        $result = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty);
481 6
        return $result;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $result also could return the type array which is incompatible with the documented return type string.
Loading history...
482
    }
483
484
    /**
485
     * Returns the configuration of an indexer for a special indexingConfiguration. By default an empty
486
     * array is returned.
487
     *
488
     * plugin.tx_solr.index.queue.<configurationName>.indexer.
489
     *
490
     * @param string $configurationName
491
     * @param array $defaultIfEmpty
492
     * @return array
493
     */
494 6
    public function getIndexQueueIndexerConfigurationByConfigurationName($configurationName, $defaultIfEmpty = [])
495
    {
496 6
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.indexer.';
497 6
        $result = $this->getObjectByPathOrDefault($path, $defaultIfEmpty);
498 6
        return $result;
499
    }
500
501
    /**
502
     * Returns all solr fields names where a mapping configuration is set for a certain index configuration
503
     *
504
     * Returns all keys from
505
     * plugin.tx_solr.index.queue.<configurationName>.fields.
506
     *
507
     * @param string $configurationName
508
     * @param array $defaultIfEmpty
509
     * @return array
510
     */
511 47
    public function getIndexQueueMappedFieldsByConfigurationName($configurationName = '', $defaultIfEmpty = [])
512
    {
513 47
        $mappingConfiguration = $this->getIndexQueueFieldsConfigurationByConfigurationName($configurationName);
514 47
        $mappedFieldNames = $this->getOnlyArrayKeysWhereValueIsNotAnArray($mappingConfiguration);
515 47
        return count($mappedFieldNames) == 0 ? $defaultIfEmpty : $mappedFieldNames;
516
    }
517
518
    /**
519
     * This method is used to check if an index queue configuration is enabled or not
520
     *
521
     * plugin.tx_solr.index.queue.<configurationName> = 1
522
     *
523
     * @param string $configurationName
524
     * @param bool $defaultIfEmpty
525
     * @return bool
526
     */
527 66
    public function getIndexQueueConfigurationIsEnabled($configurationName, $defaultIfEmpty = false)
528
    {
529 66
        $path = 'plugin.tx_solr.index.queue.' . $configurationName;
530 66
        $result = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty);
531 66
        return $this->getBool($result);
532
    }
533
534
    /**
535
     * Retrieves an array of enabled index queue configurations.
536
     *
537
     * plugin.tx_solr.index.queue.<configurationName>
538
     *
539
     * @param array $defaultIfEmpty
540
     * @return array
541
     */
542 73
    public function getEnabledIndexQueueConfigurationNames($defaultIfEmpty = [])
543
    {
544 73
        $tablesToIndex = [];
545 73
        $path = 'plugin.tx_solr.index.queue.';
546 73
        $indexQueueConfiguration = $this->getObjectByPathOrDefault($path, []);
547 73
        foreach ($indexQueueConfiguration as $configurationName => $indexingEnabled) {
548 71
            if (substr($configurationName, -1) != '.' && $indexingEnabled) {
549 71
                $tablesToIndex[] = $configurationName;
550
            }
551
        }
552
553 73
        return count($tablesToIndex) == 0 ? $defaultIfEmpty : $tablesToIndex;
554
    }
555
556
    /**
557
     * Retrieves an array of additional fields that will trigger an recursive update of pages
558
     * when some of the fields on that page are modified.
559
     *
560
     * plugin.tx_solr.index.queue.recursiveUpdateFields
561
     *
562
     * @param string $configurationName
563
     * @param array $defaultIfEmpty
564
     * @return array
565
     */
566 26
    public function getIndexQueueConfigurationRecursiveUpdateFields($configurationName, $defaultIfEmpty = [])
567
    {
568 26
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.recursiveUpdateFields';
569 26
        $recursiveUpdateFieldsString = $this->getValueByPathOrDefaultValue($path, '');
570 26
        if (trim($recursiveUpdateFieldsString) === '') {
0 ignored issues
show
Bug introduced by
It seems like $recursiveUpdateFieldsString can also be of type array; however, parameter $str of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

570
        if (trim(/** @scrutinizer ignore-type */ $recursiveUpdateFieldsString) === '') {
Loading history...
571 20
            return $defaultIfEmpty;
572
        }
573 7
        $recursiveUpdateFields = GeneralUtility::trimExplode(',', $recursiveUpdateFieldsString);
0 ignored issues
show
Bug introduced by
It seems like $recursiveUpdateFieldsString can also be of type array; however, parameter $string of TYPO3\CMS\Core\Utility\G...lUtility::trimExplode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

573
        $recursiveUpdateFields = GeneralUtility::trimExplode(',', /** @scrutinizer ignore-type */ $recursiveUpdateFieldsString);
Loading history...
574
        // For easier check later on we return an array by combining $recursiveUpdateFields
575 7
        return array_combine($recursiveUpdateFields, $recursiveUpdateFields);
576
    }
577
578
579
    /**
580
     * Retrieves and initialPagesAdditionalWhereClause where clause when configured or an empty string.
581
     *
582
     * plugin.tx_solr.index.queue.<configurationName>.initialPagesAdditionalWhereClause
583
     *
584
     * @param string $configurationName
585
     * @return string
586
     */
587 13
    public function getInitialPagesAdditionalWhereClause($configurationName)
588
    {
589 13
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.initialPagesAdditionalWhereClause';
590 13
        $initialPagesAdditionalWhereClause = $this->getValueByPathOrDefaultValue($path, '');
591
592 13
        if (trim($initialPagesAdditionalWhereClause) === '') {
0 ignored issues
show
Bug introduced by
It seems like $initialPagesAdditionalWhereClause can also be of type array; however, parameter $str of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

592
        if (trim(/** @scrutinizer ignore-type */ $initialPagesAdditionalWhereClause) === '') {
Loading history...
593 13
            return '';
594
        }
595
596 1
        return ' AND ' . $initialPagesAdditionalWhereClause;
0 ignored issues
show
Bug introduced by
Are you sure $initialPagesAdditionalWhereClause of type string|array can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

596
        return ' AND ' . /** @scrutinizer ignore-type */ $initialPagesAdditionalWhereClause;
Loading history...
597
    }
598
599
    /**
600
     * Retrieves and additional where clause when configured or an empty string.
601
     *
602
     * plugin.tx_solr.index.queue.<configurationName>.additionalWhereClause
603
     *
604
     * @param string $configurationName
605
     * @return string
606
     */
607 69
    public function getIndexQueueAdditionalWhereClauseByConfigurationName($configurationName)
608
    {
609 69
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.additionalWhereClause';
610 69
        $additionalWhere = $this->getValueByPathOrDefaultValue($path, '');
611
612 69
        if (trim($additionalWhere) === '') {
0 ignored issues
show
Bug introduced by
It seems like $additionalWhere can also be of type array; however, parameter $str of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

612
        if (trim(/** @scrutinizer ignore-type */ $additionalWhere) === '') {
Loading history...
613 24
            return '';
614
        }
615
616 46
        return ' AND ' . $additionalWhere;
0 ignored issues
show
Bug introduced by
Are you sure $additionalWhere of type string|array can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

616
        return ' AND ' . /** @scrutinizer ignore-type */ $additionalWhere;
Loading history...
617
    }
618
619
    /**
620
     * This method can be used to retrieve all index queue configuration names, where
621
     * a certain table is used. It can be configured with the property "table" or is using the configuration
622
     * key a fallback for the table name.
623
     *
624
     * plugin.tx_solr.index.queue.<configurationName>.
625
     *
626
     * @param string $tableName
627
     * @param array $defaultIfEmpty
628
     * @return array
629
     */
630 1
    public function getIndexQueueConfigurationNamesByTableName($tableName, $defaultIfEmpty = [])
631
    {
632 1
        $path = 'plugin.tx_solr.index.queue.';
633 1
        $configuration = $this->getObjectByPathOrDefault($path, []);
634 1
        $possibleConfigurations = [];
635
636 1
        foreach ($configuration as $configurationName => $indexingEnabled) {
637 1
            $isObject = substr($configurationName, -1) === '.';
638 1
            if ($isObject || !$indexingEnabled) {
639 1
                continue;
640
            }
641
642
            // when the configuration name equals the tableName we have a fallback
643 1
            $hasTableNameAsConfigurationName = $configurationName == $tableName;
644 1
            $hasTableAssignedInQueueConfiguration = isset($configuration[$configurationName . '.']['table']) &&
645 1
                                                    $configuration[$configurationName . '.']['table'] == $tableName;
646 1
            if ($hasTableNameAsConfigurationName || $hasTableAssignedInQueueConfiguration) {
647 1
                $possibleConfigurations[] = $configurationName;
648
            }
649
        }
650
651 1
        return count($possibleConfigurations) > 0 ? $possibleConfigurations : $defaultIfEmpty;
652
    }
653
654
    /**
655
     * This method is used to retrieve the className of a queue initializer for a certain indexing configuration
656
     * of returns the default initializer class, when noting is configured.
657
     *
658
     * plugin.tx_solr.index.queue.<configurationName>.initialization
659
     *
660
     * @param string $configurationName
661
     * @param string $defaultIfEmpty
662
     * @return string
663
     */
664 6
    public function getIndexQueueInitializerClassByConfigurationName($configurationName, $defaultIfEmpty = Record::class)
665
    {
666 6
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.initialization';
667 6
        $className = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty);
668
669 6
        return $className;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $className also could return the type array which is incompatible with the documented return type string.
Loading history...
670
    }
671
672
    /**
673
     * Returns the _LOCAL_LANG configuration from the TypoScript.
674
     *
675
     * plugin.tx_solr._LOCAL_LANG.
676
     *
677
     * @param array $defaultIfEmpty
678
     * @return array
679
     */
680
    public function getLocalLangConfiguration(array $defaultIfEmpty = [])
681
    {
682
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr._LOCAL_LANG.', $defaultIfEmpty);
683
        return $result;
684
    }
685
686
    /**
687
     * When this is enabled the output of the devlog, will be printed as debug output.
688
     *
689
     * @param bool $defaultIfEmpty
690
     * @return bool
691
     */
692
    public function getLoggingDebugOutput($defaultIfEmpty = false)
693
    {
694
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.debugOutput', $defaultIfEmpty);
695
        return $this->getBool($result);
696
    }
697
698
    /**
699
     * Returns if query filters should be written to the log.
700
     *
701
     * plugin.tx_solr.logging.query.filters
702
     *
703
     * @param bool $defaultIfEmpty
704
     * @return bool
705
     */
706
    public function getLoggingQueryFilters($defaultIfEmpty = false)
707
    {
708
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.filters', $defaultIfEmpty);
709
        return $this->getBool($result);
710
    }
711
712
    /**
713
     * Returns if the querystring should be logged or not.
714
     *
715
     * plugin.tx_solr.logging.query.queryString
716
     *
717
     * @param bool $defaultIfEmpty
718
     * @return bool
719
     */
720 46
    public function getLoggingQueryQueryString($defaultIfEmpty = false)
721
    {
722 46
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.queryString', $defaultIfEmpty);
723 46
        return $this->getBool($result);
724
    }
725
726
    /**
727
     * Returns if the searchWords should be logged or not.
728
     *
729
     * plugin.tx_solr.logging.query.searchWords
730
     *
731
     * @param bool $defaultIfEmpty
732
     * @return bool
733
     */
734 123
    public function getLoggingQuerySearchWords($defaultIfEmpty = false)
735
    {
736 123
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.searchWords', $defaultIfEmpty);
737 123
        return $this->getBool($result);
738
    }
739
740
    /**
741
     * Returns if the rawGet requests should be logged or not.
742
     *
743
     * plugin.tx_solr.logging.query.rawGet
744
     *
745
     * @param bool $defaultIfEmpty
746
     * @return bool
747
     */
748 62
    public function getLoggingQueryRawGet($defaultIfEmpty = false)
749
    {
750 62
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.rawGet', $defaultIfEmpty);
751 62
        return $this->getBool($result);
752
    }
753
754
    /**
755
     * Returns if the rawPost requests should be logged or not.
756
     *
757
     * plugin.tx_solr.logging.query.rawPost
758
     *
759
     * @param bool $defaultIfEmpty
760
     * @return bool
761
     */
762 94
    public function getLoggingQueryRawPost($defaultIfEmpty = false)
763
    {
764 94
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.rawPost', $defaultIfEmpty);
765 94
        return $this->getBool($result);
766
    }
767
768
    /**
769
     * Returns if the rawDelete requests should be logged or not.
770
     *
771
     * plugin.tx_solr.logging.query.rawDelete
772
     *
773
     * @param bool $defaultIfEmpty
774
     * @return bool
775
     */
776 4
    public function getLoggingQueryRawDelete($defaultIfEmpty = false)
777
    {
778 4
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.rawDelete', $defaultIfEmpty);
779 4
        return $this->getBool($result);
780
    }
781
782
    /**
783
     * Returns if exceptions should be logged or not.
784
     *
785
     * plugin.tx_solr.logging.exceptions
786
     *
787
     * @param bool $defaultIfEmpty
788
     * @return bool
789
     */
790 12
    public function getLoggingExceptions($defaultIfEmpty = true)
791
    {
792 12
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.exceptions', $defaultIfEmpty);
793 12
        return $this->getBool($result);
794
    }
795
796
    /**
797
     * Returns if indexing operations should be logged or not.
798
     *
799
     * plugin.tx_solr.logging.indexing
800
     *
801
     * @param bool $defaultIfEmpty
802
     * @return bool
803
     */
804 22
    public function getLoggingIndexing($defaultIfEmpty = false)
805
    {
806 22
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing', $defaultIfEmpty);
807 22
        return $this->getBool($result);
808
    }
809
810
    /**
811
     * Returns if indexing queue operations should be logged or not.
812
     *
813
     * plugin.tx_solr.logging.indexing.queue
814
     *
815
     * @param bool $defaultIfEmpty
816
     * @return bool
817
     */
818 21
    public function getLoggingIndexingQueue($defaultIfEmpty = false)
819
    {
820 21
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing.queue', $defaultIfEmpty);
821 21
        return $this->getBool($result);
822
    }
823
824
    /**
825
     * This method can be used to check if the logging during indexing should be done.
826
     * It takes the specific configuration by indexQueueConfiguration into account or is using the
827
     * fallback when the logging is enabled on queue or indexing level.
828
     *
829
     * plugin.tx_solr.logging.indexing.queue.<indexQueueConfiguration>
830
     *
831
     * @param string $indexQueueConfiguration
832
     * @param bool $defaultIfEmpty
833
     * @return bool
834
     */
835 22
    public function getLoggingIndexingQueueOperationsByConfigurationNameWithFallBack($indexQueueConfiguration, $defaultIfEmpty = false)
836
    {
837
        // when logging is globally enabled we do not need to check the specific configuration
838 22
        if ($this->getLoggingIndexing()) {
839 1
            return true;
840
        }
841
842
        // when the logging for indexing is enabled on queue level we also do not need to check the specific configuration
843 21
        if ($this->getLoggingIndexingQueue()) {
844
            return true;
845
        }
846
847 21
        $path = 'plugin.tx_solr.logging.indexing.queue.' . $indexQueueConfiguration;
848 21
        $result = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty);
849 21
        return $this->getBool($result);
850
    }
851
852
    /**
853
     * Returns if a log message should be written when a page was indexed.
854
     *
855
     * plugin.tx_solr.logging.indexing.pageIndexed
856
     *
857
     * @param bool $defaultIfEmpty
858
     * @return bool
859
     */
860 10
    public function getLoggingIndexingPageIndexed($defaultIfEmpty = false)
861
    {
862 10
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing.pageIndexed', $defaultIfEmpty);
863 10
        return $this->getBool($result);
864
    }
865
866
    /**
867
     * Returns if a log message should be written when the TYPO3 search markers are missing in the page.
868
     *
869
     * plugin.tx_solr.logging.indexing.missingTypo3SearchMarkers
870
     *
871
     * @param bool $defaultIfEmpty
872
     * @return bool
873
     */
874 17
    public function getLoggingIndexingMissingTypo3SearchMarkers($defaultIfEmpty = true)
875
    {
876 17
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing.missingTypo3SearchMarkers', $defaultIfEmpty);
877 17
        return $this->getBool($result);
878
    }
879
880
    /**
881
     * Returns if the initialization of an indexqueue should be logged.
882
     *
883
     * plugin.tx_solr.logging.indexing.indexQueueInitialization
884
     *
885
     * @param bool $defaultIfEmpty
886
     * @return bool
887
     */
888 12
    public function getLoggingIndexingIndexQueueInitialization($defaultIfEmpty = false)
889
    {
890 12
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing.indexQueueInitialization', $defaultIfEmpty);
891 12
        return $this->getBool($result);
892
    }
893
894
    /**
895
     * Indicates if the debug mode is enabled or not.
896
     *
897
     * plugin.tx_solr.enableDebugMode
898
     *
899
     * @param bool $defaultIfEmpty
900
     * @return bool
901
     */
902 37
    public function getEnabledDebugMode($defaultIfEmpty = false)
903
    {
904 37
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.enableDebugMode', $defaultIfEmpty);
905 37
        return $this->getBool($result);
906
    }
907
908
    /**
909
     * Returns true or false if something is configured below plugin.tx_solr.solr.
910
     *
911
     * plugin.tx_solr.solr.
912
     *
913
     * @param boolean $defaultIfEmpty
914
     * @return boolean
915
     */
916 3
    public function getSolrHasConnectionConfiguration($defaultIfEmpty = false)
917
    {
918 3
        $configuration = $this->getObjectByPathOrDefault('plugin.tx_solr.solr.', []);
919 3
        return $configuration !== [] ? true : $defaultIfEmpty;
920
    }
921
922
    /**
923
     * Returns the defaultTimeout used for requests to the Solr server
924
     *
925
     * plugin.tx_solr.solr.timeout
926
     *
927
     * @param float $defaultIfEmpty
928
     * @return float
929
     */
930 115
    public function getSolrTimeout($defaultIfEmpty = 0.0)
931
    {
932 115
        return (float)$this->getValueByPathOrDefaultValue('plugin.tx_solr.solr.timeout', $defaultIfEmpty);
933
    }
934
935
    /**
936
     * Returns the scheme used for requests to the Solr server
937
     *
938
     * plugin.tx_solr.solr.scheme
939
     *
940
     * Applies stdWrap on the configured setting
941
     *
942
     * @param string $defaultIfEmpty
943
     * @return string
944
     */
945 4
    public function getSolrScheme($defaultIfEmpty = 'http')
946
    {
947 4
        $valuePath = 'plugin.tx_solr.solr.scheme';
948 4
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
949 4
        return $this->renderContentElementOfConfigured($valuePath, $value);
950
    }
951
952
    /**
953
     * Returns the hostname used for requests to the Solr server
954
     *
955
     * plugin.tx_solr.solr.host
956
     *
957
     * Applies stdWrap on the configured setting
958
     *
959
     * @param string $defaultIfEmpty
960
     * @return string
961
     */
962 7
    public function getSolrHost($defaultIfEmpty = 'localhost')
963
    {
964 7
        $valuePath = 'plugin.tx_solr.solr.host';
965 7
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
966 7
        return $this->renderContentElementOfConfigured($valuePath, $value);
967
    }
968
969
    /**
970
     * Returns the port used for requests to the Solr server
971
     *
972
     * plugin.tx_solr.solr.port
973
     *
974
     * Applies stdWrap on the configured setting
975
     *
976
     * @param int $defaultIfEmpty
977
     * @return int
978
     */
979 4
    public function getSolrPort($defaultIfEmpty = 8983)
980
    {
981 4
        $valuePath = 'plugin.tx_solr.solr.port';
982 4
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
983 4
        return $this->renderContentElementOfConfigured($valuePath, $value);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->renderCont...red($valuePath, $value) returns the type string which is incompatible with the documented return type integer.
Loading history...
984
    }
985
986
    /**
987
     * Returns the path used for requests to the Solr server
988
     *
989
     * plugin.tx_solr.solr.path
990
     *
991
     * Applies stdWrap on the configured setting
992
     *
993
     * @param string $defaultIfEmpty
994
     * @return string
995
     */
996 7
    public function getSolrPath($defaultIfEmpty = '/solr/core_en/')
997
    {
998 7
        $valuePath = 'plugin.tx_solr.solr.path';
999 7
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
1000 7
        $solrPath = $this->renderContentElementOfConfigured($valuePath, $value);
1001
1002 7
        $solrPath = trim($solrPath, '/');
1003 7
        $solrPath = '/' . $solrPath . '/';
1004
1005 7
        return $solrPath;
1006
    }
1007
1008
    /**
1009
     * Returns the username used for requests to the Solr server
1010
     *
1011
     * plugin.tx_solr.solr.username
1012
     *
1013
     * Applies stdWrap on the configured setting
1014
     *
1015
     * @param string $defaultIfEmpty
1016
     * @return string
1017
     */
1018 4
    public function getSolrUsername($defaultIfEmpty = '')
1019
    {
1020 4
        $valuePath = 'plugin.tx_solr.solr.username';
1021 4
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
1022 4
        return $this->renderContentElementOfConfigured($valuePath, $value);
1023
    }
1024
1025
    /**
1026
     * Returns the password used for requests to the Solr server
1027
     *
1028
     * plugin.tx_solr.solr.password
1029
     *
1030
     * Applies stdWrap on the configured setting
1031
     *
1032
     * @param string $defaultIfEmpty
1033
     * @return string
1034
     */
1035 4
    public function getSolrPassword($defaultIfEmpty = '')
1036
    {
1037 4
        $valuePath = 'plugin.tx_solr.solr.password';
1038 4
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
1039 4
        return $this->renderContentElementOfConfigured($valuePath, $value);
1040
    }
1041
1042
    /**
1043
     * Retrieves the complete search configuration
1044
     *
1045
     * plugin.tx_solr.search.
1046
     *
1047
     * @param array $defaultIfEmpty
1048
     * @return array
1049
     */
1050 50
    public function getSearchConfiguration(array $defaultIfEmpty = [])
1051
    {
1052 50
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.', $defaultIfEmpty);
1053 50
        return $result;
1054
    }
1055
1056
    /**
1057
     * Indicates if elevation should be used or not
1058
     *
1059
     * plugin.tx_solr.search.elevation
1060
     *
1061
     * @param bool $defaultIfEmpty
1062
     * @return bool
1063
     */
1064 37
    public function getSearchElevation($defaultIfEmpty = false)
1065
    {
1066 37
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.elevation', $defaultIfEmpty);
1067 37
        return $this->getBool($result);
1068
    }
1069
1070
    /**
1071
     * Indicates if elevated results should be marked
1072
     *
1073
     * plugin.tx_solr.search.elevation.markElevatedResults
1074
     *
1075
     * @param bool $defaultIfEmpty
1076
     * @return bool
1077
     */
1078 32
    public function getSearchElevationMarkElevatedResults($defaultIfEmpty = true)
1079
    {
1080 32
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.elevation.markElevatedResults', $defaultIfEmpty);
1081 32
        return $this->getBool($result);
1082
    }
1083
1084
    /**
1085
     * Indicates if elevation should be forced
1086
     *
1087
     *plugin.tx_solr.search.elevation.forceElevation
1088
     *
1089
     * @param bool $defaultIfEmpty
1090
     * @return bool
1091
     */
1092 32
    public function getSearchElevationForceElevation($defaultIfEmpty = true)
1093
    {
1094 32
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.elevation.forceElevation', $defaultIfEmpty);
1095 32
        return $this->getBool($result);
1096
    }
1097
1098
    /**
1099
     * Indicates if collapsing on a certain field should be used to build variants or not.
1100
     *
1101
     * plugin.tx_solr.search.variants
1102
     *
1103
     * @param bool $defaultIfEmpty
1104
     * @return bool
1105
     */
1106 123
    public function getSearchVariants($defaultIfEmpty = false)
1107
    {
1108 123
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.variants', $defaultIfEmpty);
1109 123
        return $this->getBool($result);
1110
    }
1111
1112
    /**
1113
     * Indicates if collapsing on a certain field should be used or not
1114
     *
1115
     * plugin.tx_solr.search.variants.variantField
1116
     *
1117
     * @param string $defaultIfEmpty
1118
     * @return string
1119
     */
1120 5
    public function getSearchVariantsField($defaultIfEmpty = 'variantId')
1121
    {
1122 5
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.variants.variantField', $defaultIfEmpty);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...ield', $defaultIfEmpty) also could return the type array which is incompatible with the documented return type string.
Loading history...
1123
    }
1124
1125
    /**
1126
     * Indicates if expanding of collapsed items it activated.
1127
     *
1128
     * plugin.tx_solr.search.variants.expand
1129
     *
1130
     * @param bool $defaultIfEmpty
1131
     * @return bool
1132
     */
1133 5
    public function getSearchVariantsExpand($defaultIfEmpty = false)
1134
    {
1135 5
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.variants.expand', $defaultIfEmpty);
1136 5
        return $this->getBool($result);
1137
    }
1138
1139
    /**
1140
     * Retrieves the number of elements that should be expanded.
1141
     *
1142
     * plugin.tx_solr.search.variants.limit
1143
     *
1144
     * @param int $defaultIfEmpty
1145
     * @return int
1146
     */
1147 5
    public function getSearchVariantsLimit($defaultIfEmpty = 10)
1148
    {
1149 5
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.variants.limit', $defaultIfEmpty);
1150 5
        return (int)$result;
1151
    }
1152
1153
    /**
1154
     * Indicates if frequent searches should be show or not.
1155
     *
1156
     * plugin.tx_solr.search.frequentSearches
1157
     *
1158
     * @param bool $defaultIfEmpty
1159
     * @return bool
1160
     */
1161 30
    public function getSearchFrequentSearches($defaultIfEmpty = false)
1162
    {
1163 30
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches', $defaultIfEmpty);
1164 30
        return $this->getBool($result);
1165
    }
1166
1167
    /**
1168
     * Returns the sub configuration of the frequentSearches
1169
     *
1170
     * plugin.tx_solr.search.frequentSearches.
1171
     *
1172
     * @param array $defaultIfEmpty
1173
     * @return array
1174
     */
1175 33
    public function getSearchFrequentSearchesConfiguration($defaultIfEmpty = [])
1176
    {
1177 33
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.frequentSearches.', $defaultIfEmpty);
1178 33
        return $result;
1179
    }
1180
1181
    /**
1182
     * Retrieves the minimum font size that should be used for the frequentSearches.
1183
     *
1184
     * plugin.tx_solr.search.frequentSearches.minSize
1185
     *
1186
     * @param int $defaultIfEmpty
1187
     * @return int
1188
     */
1189 33
    public function getSearchFrequentSearchesMinSize($defaultIfEmpty = 14)
1190
    {
1191 33
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches.minSize', $defaultIfEmpty);
1192 33
        return (int)$result;
1193
    }
1194
1195
    /**
1196
     * Retrieves the maximum font size that should be used for the frequentSearches.
1197
     *
1198
     * plugin.tx_solr.search.frequentSearches.minSize
1199
     *
1200
     * @param int $defaultIfEmpty
1201
     * @return int
1202
     */
1203 33
    public function getSearchFrequentSearchesMaxSize($defaultIfEmpty = 32)
1204
    {
1205 33
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches.maxSize', $defaultIfEmpty);
1206 33
        return (int)$result;
1207
    }
1208
1209
    /**
1210
     * Indicates if frequent searches should be show or not.
1211
     *
1212
     * plugin.tx_solr.search.frequentSearches.useLowercaseKeywords
1213
     *
1214
     * @param bool $defaultIfEmpty
1215
     * @return bool
1216
     */
1217 31
    public function getSearchFrequentSearchesUseLowercaseKeywords($defaultIfEmpty = false)
1218
    {
1219 31
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches.useLowercaseKeywords', $defaultIfEmpty);
1220 31
        return $this->getBool($result);
1221
    }
1222
1223
    /**
1224
     * Returns the configuration if the search should be initialized with an empty query.
1225
     *
1226
     * plugin.tx_solr.search.initializeWithEmptyQuery
1227
     *
1228
     * @param bool $defaultIfEmpty
1229
     * @return bool
1230
     */
1231 125
    public function getSearchInitializeWithEmptyQuery($defaultIfEmpty = false)
1232
    {
1233 125
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.initializeWithEmptyQuery', $defaultIfEmpty);
1234 125
        return $this->getBool($result);
1235
    }
1236
1237
    /**
1238
     * Returns the configured initial query
1239
     *
1240
     * plugin.tx_solr.search.initializeWithQuery
1241
     *
1242
     * @param string $defaultIfEmpty
1243
     * @return string
1244
     */
1245 125
    public function getSearchInitializeWithQuery($defaultIfEmpty = '')
1246
    {
1247 125
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.initializeWithQuery', $defaultIfEmpty);
1248 125
        return (string)$result;
1249
    }
1250
1251
    /**
1252
     * Returns if the last searches should be displayed or not.
1253
     *
1254
     * plugin.tx_solr.search.lastSearches
1255
     *
1256
     * @param bool $defaultIfEmpty
1257
     * @return bool
1258
     */
1259 30
    public function getSearchLastSearches($defaultIfEmpty = false)
1260
    {
1261 30
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.lastSearches', $defaultIfEmpty);
1262 30
        return $this->getBool($result);
1263
    }
1264
1265
    /**
1266
     * Returns the lastSearch mode. "user" for user specific
1267
     *
1268
     * plugin.tx_solr.search.lastSearches.mode
1269
     *
1270
     * @param string $defaultIfEmpty
1271
     * @return string
1272
     */
1273 33
    public function getSearchLastSearchesMode($defaultIfEmpty = 'user')
1274
    {
1275 33
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.lastSearches.mode', $defaultIfEmpty);
1276 33
        return (string)$result;
1277
    }
1278
1279
    /**
1280
     * Returns the lastSearch limit
1281
     *
1282
     * plugin.tx_solr.search.lastSearches.limit
1283
     *
1284
     * @param int $defaultIfEmpty
1285
     * @return int
1286
     */
1287 33
    public function getSearchLastSearchesLimit($defaultIfEmpty = 10)
1288
    {
1289 33
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.lastSearches.limit', $defaultIfEmpty);
1290 33
        return (int)$result;
1291
    }
1292
1293
    /**
1294
     * Indicates if the results of an initial empty query should be shown or not.
1295
     *
1296
     * plugin.tx_solr.search.showResultsOfInitialEmptyQuery
1297
     *
1298
     * @param bool $defaultIfEmpty
1299
     * @return bool
1300
     */
1301 7
    public function getSearchShowResultsOfInitialEmptyQuery($defaultIfEmpty = false)
1302
    {
1303 7
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.showResultsOfInitialEmptyQuery', $defaultIfEmpty);
1304 7
        return $this->getBool($result);
1305
    }
1306
1307
    /**
1308
     * Indicates if the results of an initial search query should be shown.
1309
     *
1310
     * plugin.tx_solr.search.showResultsOfInitialQuery
1311
     *
1312
     * @param bool $defaultIfEmpty
1313
     * @return bool
1314
     */
1315 5
    public function getSearchShowResultsOfInitialQuery($defaultIfEmpty = false)
1316
    {
1317 5
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.showResultsOfInitialQuery', $defaultIfEmpty);
1318 5
        return $this->getBool($result);
1319
    }
1320
1321
    /**
1322
     * Indicates if sorting was enabled or not.
1323
     *
1324
     * plugin.tx_solr.search.sorting
1325
     *
1326
     * @param bool $defaultIfEmpty
1327
     * @return bool
1328
     */
1329 65
    public function getSearchSorting($defaultIfEmpty = false)
1330
    {
1331 65
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.sorting', $defaultIfEmpty);
1332 65
        return $this->getBool($result);
1333
    }
1334
1335
    /**
1336
     * Returns the sorting options configurations.
1337
     *
1338
     * plugin.tx_solr.search.sorting.options.
1339
     *
1340
     * @param array $defaultIfEmpty
1341
     * @return array
1342
     */
1343 33
    public function getSearchSortingOptionsConfiguration($defaultIfEmpty = [])
1344
    {
1345 33
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.sorting.options.', $defaultIfEmpty);
1346 33
        return $result;
1347
    }
1348
1349
    /**
1350
     * Retrieves the sorting default order for a sort option.
1351
     *
1352
     * plugin.tx_solr.search.sorting.options.<sortOptionName>.defaultOrder
1353
     *
1354
     * or
1355
     *
1356
     * plugin.tx_solr.search.sorting.defaultOrder
1357
     *
1358
     *
1359
     * @param string $sortOptionName
1360
     * @param string $defaultIfEmpty
1361
     * @return string
1362
     */
1363 36
    public function getSearchSortingDefaultOrderBySortOptionName($sortOptionName = '', $defaultIfEmpty = 'asc')
1364
    {
1365 36
        $sortOrderSpecificPath = 'plugin.tx_solr.search.sorting.options.' . $sortOptionName . '.defaultOrder';
1366 36
        $specificSortOrder = $this->getValueByPathOrDefaultValue($sortOrderSpecificPath, null);
1367
1368
        // if we have a concrete setting, use it
1369 36
        if ($specificSortOrder !== null) {
1370 2
            return mb_strtolower($specificSortOrder);
0 ignored issues
show
Bug introduced by
$specificSortOrder of type array is incompatible with the type string expected by parameter $str of mb_strtolower(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1370
            return mb_strtolower(/** @scrutinizer ignore-type */ $specificSortOrder);
Loading history...
1371
        }
1372
1373
        // no specific setting, check common setting
1374 34
        $commonPath = 'plugin.tx_solr.search.sorting.defaultOrder';
1375 34
        $commonATagParamOrDefaultValue = $this->getValueByPathOrDefaultValue($commonPath, $defaultIfEmpty);
1376 34
        return mb_strtolower($commonATagParamOrDefaultValue);
1377
    }
1378
1379
    /**
1380
     * Returns the configured fixedOrder, if nothing configured defaultIfEmpty will be returned.
1381
     *
1382
     * plugin.tx_solr.search.sorting.options.<sortOptionName>.fixedOrder
1383
     *
1384
     * @param string $sortOptionName
1385
     * @param string $defaultIfEmpty
1386
     * @return string
1387
     */
1388
    public function getSearchSortingFixedOrderBySortOptionName($sortOptionName = '', $defaultIfEmpty = '')
1389
    {
1390
        $fixedOrder = 'plugin.tx_solr.search.sorting.options.' . $sortOptionName . '.fixedOrder';
1391
        return mb_strtolower($this->getValueByPathOrDefaultValue($fixedOrder, $defaultIfEmpty));
0 ignored issues
show
Bug introduced by
It seems like $this->getValueByPathOrD...Order, $defaultIfEmpty) can also be of type array; however, parameter $str of mb_strtolower() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1391
        return mb_strtolower(/** @scrutinizer ignore-type */ $this->getValueByPathOrDefaultValue($fixedOrder, $defaultIfEmpty));
Loading history...
1392
    }
1393
1394
    /**
1395
     * Returns the trusted fields configured for the search that do not need to be escaped.
1396
     *
1397
     * @param array $defaultIfEmpty
1398
     * @return array
1399
     */
1400 40
    public function getSearchTrustedFieldsArray($defaultIfEmpty = ['url'])
1401
    {
1402 40
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.trustedFields', '');
1403
1404 40
        if (trim($result) === '') {
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array; however, parameter $str of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1404
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
1405 3
            return $defaultIfEmpty;
1406
        }
1407
1408 37
        return GeneralUtility::trimExplode(',', $result);
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array; however, parameter $string of TYPO3\CMS\Core\Utility\G...lUtility::trimExplode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1408
        return GeneralUtility::trimExplode(',', /** @scrutinizer ignore-type */ $result);
Loading history...
1409
    }
1410
1411
    /**
1412
     * Indicates if the plugin arguments should be kept in the search form for a second submission.
1413
     *
1414
     * plugin.tx_solr.search.keepExistingParametersForNewSearches
1415
     *
1416
     * @param bool $defaultIfEmpty
1417
     * @return bool
1418
     */
1419
    public function getSearchKeepExistingParametersForNewSearches($defaultIfEmpty = false)
1420
    {
1421
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.keepExistingParametersForNewSearches', $defaultIfEmpty);
1422
        return $this->getBool($result);
1423
    }
1424
1425
    /**
1426
     * Returns if an empty query is allowed on the query level.
1427
     *
1428
     * plugin.tx_solr.search.query.allowEmptyQuery
1429
     *
1430
     * @param string $defaultIfEmpty
1431
     * @return bool
1432
     */
1433 120
    public function getSearchQueryAllowEmptyQuery($defaultIfEmpty = '')
1434
    {
1435 120
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.allowEmptyQuery', $defaultIfEmpty);
1436 120
        return $this->getBool($result);
1437
    }
1438
1439
    /**
1440
     * Returns the filter configuration array
1441
     *
1442
     * plugin.tx_solr.search.query.filter.
1443
     *
1444
     * @param array $defaultIfEmpty
1445
     * @return array
1446
     */
1447 133
    public function getSearchQueryFilterConfiguration(array $defaultIfEmpty = [])
1448
    {
1449 133
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.query.filter.', $defaultIfEmpty);
1450 133
        return $result;
1451
    }
1452
1453
    /**
1454
     * Can be used to overwrite the filterConfiguration.
1455
     *
1456
     * plugin.tx_solr.search.query.filter.
1457
     *
1458
     * @param array $configuration
1459
     */
1460 1
    public function setSearchQueryFilterConfiguration(array $configuration)
1461
    {
1462 1
        $this->configurationAccess->set('plugin.tx_solr.search.query.filter.', $configuration);
1463 1
    }
1464
1465
    /**
1466
     * Removes the pageSections filter setting.
1467
     *
1468
     * @return void
1469
     */
1470 3
    public function removeSearchQueryFilterForPageSections()
1471
    {
1472 3
        $this->configurationAccess->reset('plugin.tx_solr.search.query.filter.__pageSections');
1473 3
    }
1474
1475
    /**
1476
     * Returns the configured queryFields from TypoScript
1477
     *
1478
     * plugin.tx_solr.search.query.queryFields
1479
     *
1480
     * @param string $defaultIfEmpty
1481
     * @return string
1482
     */
1483 123
    public function getSearchQueryQueryFields($defaultIfEmpty = '')
1484
    {
1485 123
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.queryFields', $defaultIfEmpty);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...elds', $defaultIfEmpty) also could return the type array which is incompatible with the documented return type string.
Loading history...
1486
    }
1487
1488
    /**
1489
     * This method is used to check if a phrase search is enabled or not
1490
     *
1491
     * plugin.tx_solr.search.query.phrase = 1
1492
     *
1493
     * @param bool $defaultIfEmpty
1494
     * @return bool
1495
     */
1496 123
    public function getPhraseSearchIsEnabled(bool $defaultIfEmpty = false)
1497
    {
1498 123
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.phrase', $defaultIfEmpty);
1499 123
        return $this->getBool($result);
1500
    }
1501
1502
    /**
1503
     * Returns the configured phrase fields from TypoScript
1504
     *
1505
     * plugin.tx_solr.search.query.phrase.fields
1506
     *
1507
     * @param string $defaultIfEmpty
1508
     * @return string
1509
     */
1510 2
    public function getSearchQueryPhraseFields(string $defaultIfEmpty = '')
1511
    {
1512 2
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.phrase.fields', $defaultIfEmpty);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...elds', $defaultIfEmpty) also could return the type array which is incompatible with the documented return type string.
Loading history...
1513
    }
1514
1515
    /**
1516
     * This method is used to check if a bigram phrase search is enabled or not
1517
     *
1518
     * plugin.tx_solr.search.query.bigramPhrase = 1
1519
     *
1520
     * @param bool $defaultIfEmpty
1521
     * @return bool
1522
     */
1523 123
    public function getBigramPhraseSearchIsEnabled(bool $defaultIfEmpty = false)
1524
    {
1525 123
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.bigramPhrase', $defaultIfEmpty);
1526 123
        return $this->getBool($result);
1527
    }
1528
1529
    /**
1530
     * Returns the configured phrase fields from TypoScript
1531
     *
1532
     * plugin.tx_solr.search.query.bigramPhrase.fields
1533
     *
1534
     * @param string $defaultIfEmpty
1535
     * @return string
1536
     */
1537 2
    public function getSearchQueryBigramPhraseFields(string $defaultIfEmpty = '')
1538
    {
1539 2
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.bigramPhrase.fields', $defaultIfEmpty);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...elds', $defaultIfEmpty) also could return the type array which is incompatible with the documented return type string.
Loading history...
1540
    }
1541
1542
    /**
1543
     * This method is used to check if a trigram phrase search is enabled or not
1544
     *
1545
     * plugin.tx_solr.search.query.trigramPhrase = 1
1546
     *
1547
     * @param bool $defaultIfEmpty
1548
     * @return bool
1549
     */
1550 123
    public function getTrigramPhraseSearchIsEnabled(bool $defaultIfEmpty = false)
1551
    {
1552 123
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.trigramPhrase', $defaultIfEmpty);
1553 123
        return $this->getBool($result);
1554
    }
1555
1556
    /**
1557
     * Returns the configured trigram phrase fields from TypoScript
1558
     *
1559
     * plugin.tx_solr.search.query.trigramPhrase.fields
1560
     *
1561
     * @param string $defaultIfEmpty
1562
     * @return string
1563
     */
1564 2
    public function getSearchQueryTrigramPhraseFields(string $defaultIfEmpty = '')
1565
    {
1566 2
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.trigramPhrase.fields', $defaultIfEmpty);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...elds', $defaultIfEmpty) also could return the type array which is incompatible with the documented return type string.
Loading history...
1567
    }
1568
1569
    /**
1570
     * Returns the configured returnFields as array.
1571
     *
1572
     * plugin.tx_solr.search.query.returnFields
1573
     *
1574
     * @param array $defaultIfEmpty
1575
     * @return array
1576
     */
1577 125
    public function getSearchQueryReturnFieldsAsArray($defaultIfEmpty = [])
1578
    {
1579 125
        $returnFields = $this->getValueByPath('plugin.tx_solr.search.query.returnFields');
1580 125
        if (is_null($returnFields)) {
1581 87
            return $defaultIfEmpty;
1582
        }
1583
1584 38
        return GeneralUtility::trimExplode(',', $returnFields);
0 ignored issues
show
Bug introduced by
$returnFields of type array is incompatible with the type string expected by parameter $string of TYPO3\CMS\Core\Utility\G...lUtility::trimExplode(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1584
        return GeneralUtility::trimExplode(',', /** @scrutinizer ignore-type */ $returnFields);
Loading history...
1585
    }
1586
1587
    /**
1588
     * Returns the configured target page for the search.
1589
     * By default the contextPageId will be used
1590
     *
1591
     * plugin.tx_solr.search.targetPage
1592
     *
1593
     * @return int
1594
     */
1595 36
    public function getSearchTargetPage()
1596
    {
1597 36
        $targetPage = (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.targetPage', 0);
1598 36
        if ($targetPage === 0) {
1599
            // when no specific page was configured we use the contextPageId (which is usual $GLOBALS['TSFE']->id)
1600 36
            $targetPage = $this->contextPageId;
1601
        }
1602
1603 36
        return $targetPage;
1604
    }
1605
1606
    /**
1607
     * Retrieves the targetPage configuration.
1608
     *
1609
     * plugin.tx_solr.search.targetPage.
1610
     *
1611
     * @param array $defaultIfEmpty
1612
     * @return array
1613
     */
1614
    public function getSearchTargetPageConfiguration(array $defaultIfEmpty = [])
1615
    {
1616
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.targetPage.', $defaultIfEmpty);
1617
        return $result;
1618
    }
1619
1620
    /**
1621
     * Method to check if the site highlighting is enabled. When the siteHighlighting is enabled the
1622
     * sword_list parameter is added to the results link.
1623
     *
1624
     * plugin.tx_solr.searcb.results.siteHighlighting
1625
     *
1626
     * @param bool $defaultIfEmpty
1627
     * @return bool
1628
     */
1629 26
    public function getSearchResultsSiteHighlighting($defaultIfEmpty = true)
1630
    {
1631 26
        $isSiteHightlightingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.siteHighlighting', $defaultIfEmpty);
1632 26
        return $this->getBool($isSiteHightlightingEnabled);
1633
    }
1634
1635
1636
    /**
1637
     * Can be used to check if the highlighting is enabled
1638
     *
1639
     * plugin.tx_solr.search.results.resultsHighlighting
1640
     *
1641
     * @param boolean $defaultIfEmpty
1642
     * @return string
1643
     */
1644 123
    public function getSearchResultsHighlighting($defaultIfEmpty = false)
1645
    {
1646 123
        $isHighlightingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsHighlighting', $defaultIfEmpty);
1647 123
        return $this->getBool($isHighlightingEnabled);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getBool($isHighlightingEnabled) returns the type boolean which is incompatible with the documented return type string.
Loading history...
1648
    }
1649
1650
    /**
1651
     * Returns the result highlighting fields.
1652
     *
1653
     * plugin.tx_solr.search.results.resultsHighlighting.highlightFields
1654
     *
1655
     * @param string $defaultIfEmpty
1656
     * @return string
1657
     */
1658 40
    public function getSearchResultsHighlightingFields($defaultIfEmpty = '')
1659
    {
1660 40
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsHighlighting.highlightFields', $defaultIfEmpty);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...elds', $defaultIfEmpty) also could return the type array which is incompatible with the documented return type string.
Loading history...
1661
    }
1662
1663
    /**
1664
     * Returns the result highlighting fields as array.
1665
     *
1666
     * plugin.tx_solr.search.results.resultsHighlighting.highlightFields
1667
     *
1668
     * @param array $defaultIfEmpty
1669
     * @return array
1670
     */
1671
    public function getSearchResultsHighlightingFieldsAsArray($defaultIfEmpty = [])
1672
    {
1673
        $highlightingFields = $this->getSearchResultsHighlightingFields('');
1674
1675
        if ($highlightingFields === '') {
1676
            return $defaultIfEmpty;
1677
        }
1678
1679
        return GeneralUtility::trimExplode(',', $highlightingFields, true);
1680
    }
1681
1682
    /**
1683
     * Returns the fragmentSize for highlighted segments.
1684
     *
1685
     * plugin.tx_solr.search.results.resultsHighlighting.fragmentSize
1686
     *
1687
     * @param int $defaultIfEmpty
1688
     * @return int
1689
     */
1690 40
    public function getSearchResultsHighlightingFragmentSize($defaultIfEmpty = 200)
1691
    {
1692 40
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsHighlighting.fragmentSize', $defaultIfEmpty);
1693
    }
1694
1695
    /**
1696
     * Returns the fragmentSeparator for highlighted segments.
1697
     *
1698
     * plugin.tx_solr.search.results.resultsHighlighting.fragmentSeparator
1699
     *
1700
     * @param string $defaultIfEmpty
1701
     * @return string
1702
     */
1703 26
    public function getSearchResultsHighlightingFragmentSeparator($defaultIfEmpty = '[...]')
1704
    {
1705 26
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsHighlighting.fragmentSeparator', $defaultIfEmpty);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...ator', $defaultIfEmpty) also could return the type array which is incompatible with the documented return type string.
Loading history...
1706
    }
1707
1708
    /**
1709
     * Returns the number of results that should be shown per page.
1710
     *
1711
     * plugin.tx_solr.search.results.resultsPerPage
1712
     *
1713
     * @param int $defaultIfEmpty
1714
     * @return int
1715
     */
1716 35
    public function getSearchResultsPerPage($defaultIfEmpty = 10)
1717
    {
1718 35
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsPerPage', $defaultIfEmpty);
1719
    }
1720
1721
    /**
1722
     * Returns the available options for the per page switch.
1723
     *
1724
     * plugin.tx_solr.search.results.resultsPerPageSwitchOptions
1725
     *
1726
     * @param array $defaultIfEmpty
1727
     * @return array
1728
     */
1729 35
    public function getSearchResultsPerPageSwitchOptionsAsArray($defaultIfEmpty = [])
1730
    {
1731 35
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsPerPageSwitchOptions', '');
1732
1733 35
        if (trim($result) === '') {
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array; however, parameter $str of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1733
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
1734
            return $defaultIfEmpty;
1735
        }
1736
1737 35
        return GeneralUtility::intExplode(',', $result, true);
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array; however, parameter $string of TYPO3\CMS\Core\Utility\G...alUtility::intExplode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1737
        return GeneralUtility::intExplode(',', /** @scrutinizer ignore-type */ $result, true);
Loading history...
1738
    }
1739
1740
    /**
1741
     * Returns the configured wrap for the resultHighlighting.
1742
     *
1743
     * plugin.tx_solr.search.results.resultsHighlighting.wrap
1744
     *
1745
     * @param string $defaultIfEmpty
1746
     * @return string
1747
     */
1748 40
    public function getSearchResultsHighlightingWrap($defaultIfEmpty = '')
1749
    {
1750 40
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsHighlighting.wrap', $defaultIfEmpty);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...wrap', $defaultIfEmpty) also could return the type array which is incompatible with the documented return type string.
Loading history...
1751
    }
1752
1753
    /**
1754
     * Indicates if spellchecking is enabled or not.
1755
     *
1756
     * plugin.tx_solr.search.spellchecking
1757
     *
1758
     * @param bool $defaultIfEmpty
1759
     * @return bool
1760
     */
1761 33
    public function getSearchSpellchecking($defaultIfEmpty = false)
1762
    {
1763 33
        $isFacetingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking', $defaultIfEmpty);
1764 33
        return $this->getBool($isFacetingEnabled);
1765
    }
1766
1767
    /**
1768
     * Returns the wrap that should be used for spellchecking
1769
     *
1770
     * plugin.tx_solr.search.spellchecking.wrap
1771
     *
1772
     * @param string $defaultIfEmpty
1773
     * @return string
1774
     */
1775
    public function getSearchSpellcheckingWrap($defaultIfEmpty = '')
1776
    {
1777
        return (string)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking.wrap', $defaultIfEmpty);
1778
    }
1779
1780
    /**
1781
     * Returns the numberOfSuggestionsToTry that should be used for the spellchecking.
1782
     *
1783
     * plugin.tx_solr.search.spellchecking.numberOfSuggestionsToTry
1784
     *
1785
     * @param int $defaultIfEmpty
1786
     * @return int
1787
     */
1788 33
    public function getSearchSpellcheckingNumberOfSuggestionsToTry($defaultIfEmpty = 1)
1789
    {
1790 33
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking.numberOfSuggestionsToTry', $defaultIfEmpty);
1791
    }
1792
1793
    /**
1794
     * Indicates if a second search should be fired from the spellchecking suggestion if no results could be found.
1795
     *
1796
     * plugin.tx_solr.search.spellchecking.searchUsingSpellCheckerSuggestion
1797
     *
1798
     * @param bool $defaultIfEmpty
1799
     * @return bool
1800
     */
1801 36
    public function getSearchSpellcheckingSearchUsingSpellCheckerSuggestion($defaultIfEmpty = false)
1802
    {
1803 36
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking.searchUsingSpellCheckerSuggestion', $defaultIfEmpty);
1804 36
        return $this->getBool($result);
1805
    }
1806
1807
    /**
1808
     * Indicates if faceting is enabled or not.
1809
     *
1810
     * plugin.tx_solr.search.faceting
1811
     *
1812
     * @param bool $defaultIfEmpty
1813
     * @return bool
1814
     */
1815 123
    public function getSearchFaceting($defaultIfEmpty = false)
1816
    {
1817 123
        $isFacetingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting', $defaultIfEmpty);
1818 123
        return $this->getBool($isFacetingEnabled);
1819
    }
1820
1821
    /**
1822
     * Retrieves the showEvenWhenEmpty for a facet by facet name. If nothing specific is configured
1823
     * the global showEmptyFacets with be returned.
1824
     *
1825
     * plugin.tx_solr.search.faceting.facets.<facetName>.showEvenWhenEmpty
1826
     *
1827
     * or
1828
     *
1829
     * plugin.tx_solr.search.faceting.showEmptyFacets
1830
     *
1831
     *
1832
     * @param string $facetName
1833
     * @param bool $defaultIfEmpty
1834
     * @return bool
1835
     */
1836 66
    public function getSearchFacetingShowEmptyFacetsByName($facetName = '', $defaultIfEmpty = false)
1837
    {
1838 66
        $facetSpecificPath = 'plugin.tx_solr.search.faceting.facets.' . $facetName . '.showEvenWhenEmpty';
1839 66
        $specificShowWhenEmpty = $this->getValueByPathOrDefaultValue($facetSpecificPath, null);
1840
1841
        // if we have a concrete setting, use it
1842 66
        if ($specificShowWhenEmpty !== null) {
1843 2
            return $specificShowWhenEmpty;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $specificShowWhenEmpty returns the type array which is incompatible with the documented return type boolean.
Loading history...
1844
        }
1845
1846
        // no specific setting, check common setting
1847 66
        $commonPath = 'plugin.tx_solr.search.faceting.showEmptyFacets';
1848 66
        $commonIfEmptyOrDefaultValue = $this->getValueByPathOrDefaultValue($commonPath, $defaultIfEmpty);
1849 66
        return $commonIfEmptyOrDefaultValue;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $commonIfEmptyOrDefaultValue also could return the type array which is incompatible with the documented return type boolean.
Loading history...
1850
    }
1851
1852
    /**
1853
     * Returns the wrap for the faceting show all link
1854
     *
1855
     * plugin.tx_solr.search.faceting.showAllLink.wrap
1856
     *
1857
     * @param string $defaultIfEmpty
1858
     * @return string
1859
     */
1860
    public function getSearchFacetingShowAllLinkWrap($defaultIfEmpty = '')
1861
    {
1862
        return (string)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.showAllLink.wrap', $defaultIfEmpty);
1863
    }
1864
1865
    /**
1866
     * Returns the link url parameters that should be added to a facet.
1867
     *
1868
     * plugin.tx_solr.search.faceting.facetLinkUrlParameters
1869
     *
1870
     * @param string $defaultIfEmpty
1871
     * @return string
1872
     */
1873 29
    public function getSearchFacetingFacetLinkUrlParameters($defaultIfEmpty = '')
1874
    {
1875 29
        $linkUrlParameters = trim($this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.facetLinkUrlParameters', $defaultIfEmpty));
0 ignored issues
show
Bug introduced by
It seems like $this->getValueByPathOrD...ters', $defaultIfEmpty) can also be of type array; however, parameter $str of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1875
        $linkUrlParameters = trim(/** @scrutinizer ignore-type */ $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.facetLinkUrlParameters', $defaultIfEmpty));
Loading history...
1876
1877 29
        return $linkUrlParameters;
1878
    }
1879
1880
    /**
1881
     * Returns if the facetLinkUrlsParameters should be included in the reset link.
1882
     *
1883
     * plugin.tx_solr.search.faceting.facetLinkUrlParameters.useForFacetResetLinkUrl
1884
     *
1885
     * @param bool $defaultIfEmpty
1886
     * @return bool
1887
     */
1888 4
    public function getSearchFacetingFacetLinkUrlParametersUseForFacetResetLinkUrl($defaultIfEmpty = true)
1889
    {
1890 4
        $useForFacetResetLinkUrl = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.facetLinkUrlParameters.useForFacetResetLinkUrl', $defaultIfEmpty);
1891 4
        return $this->getBool($useForFacetResetLinkUrl);
1892
    }
1893
1894
    /**
1895
     * Returns the link url parameters that should be added to a facet as array.
1896
     *
1897
     * plugin.tx_solr.search.faceting.facetLinkUrlParameters
1898
     *
1899
     * @param array $defaultIfEmpty
1900
     * @return array
1901
     */
1902 29
    public function getSearchFacetingFacetLinkUrlParametersAsArray($defaultIfEmpty = [])
1903
    {
1904 29
        $linkUrlParameters = $this->getSearchFacetingFacetLinkUrlParameters();
1905 29
        if ($linkUrlParameters === '') {
1906
            return $defaultIfEmpty;
1907
        }
1908
1909 29
        return GeneralUtility::explodeUrl2Array($linkUrlParameters);
1910
    }
1911
1912
    /**
1913
     * Return the configured minimumCount value for facets.
1914
     *
1915
     * plugin.tx_solr.search.faceting.minimumCount
1916
     *
1917
     * @param int $defaultIfEmpty
1918
     * @return int
1919
     */
1920 43
    public function getSearchFacetingMinimumCount($defaultIfEmpty = 1)
1921
    {
1922 43
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.minimumCount', $defaultIfEmpty);
1923
    }
1924
1925
    /**
1926
     * Return the configured limit value for facets, used for displaying.
1927
     *
1928
     * plugin.tx_solr.search.faceting.limit
1929
     *
1930
     * @param int $defaultIfEmpty
1931
     * @return int
1932
     */
1933
    public function getSearchFacetingLimit($defaultIfEmpty = 10)
1934
    {
1935
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.limit', $defaultIfEmpty);
1936
    }
1937
1938
    /**
1939
     * Return the configured limit value for facets, used for the response.
1940
     *
1941
     * plugin.tx_solr.search.faceting.facetLimit
1942
     *
1943
     * @param int $defaultIfEmpty
1944
     * @return int
1945
     */
1946 43
    public function getSearchFacetingFacetLimit($defaultIfEmpty = 100)
1947
    {
1948 43
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.facetLimit', $defaultIfEmpty);
1949
    }
1950
1951
    /**
1952
     * Returns if the singleFacetMode is active or not.
1953
     *
1954
     * plugin.tx_solr.search.faceting.singleFacetMode
1955
     *
1956
     * @param bool $defaultIfEmpty
1957
     * @return bool
1958
     */
1959
    public function getSearchFacetingSingleFacetMode($defaultIfEmpty = false)
1960
    {
1961
        $singleFacetMode = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.singleFacetMode', $defaultIfEmpty);
1962
        return $this->getBool($singleFacetMode);
1963
    }
1964
1965
    /**
1966
     * Return the configured faceting sortBy value.
1967
     *
1968
     * plugin.tx_solr.search.faceting.sortBy
1969
     *
1970
     * @param string $defaultIfEmpty
1971
     * @return string
1972
     */
1973 43
    public function getSearchFacetingSortBy($defaultIfEmpty = '')
1974
    {
1975 43
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.sortBy', $defaultIfEmpty);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...rtBy', $defaultIfEmpty) also could return the type array which is incompatible with the documented return type string.
Loading history...
1976
    }
1977
1978
    /**
1979
     * Returns if a facets should be kept on selection. Global faceting setting
1980
     * can also be configured on facet level by using
1981
     * (plugin.tx_solr.search.faceting.facets.<fieldName>.keepAllOptionsOnSelection)
1982
     *
1983
     * plugin.tx_solr.search.faceting.keepAllFacetsOnSelection
1984
     *
1985
     * @param bool $defaultIfEmpty
1986
     * @return bool
1987
     */
1988 42
    public function getSearchFacetingKeepAllFacetsOnSelection($defaultIfEmpty = false)
1989
    {
1990 42
        $keepAllOptionsOnSelection = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.keepAllFacetsOnSelection', $defaultIfEmpty);
1991 42
        return $this->getBool($keepAllOptionsOnSelection);
1992
    }
1993
1994
    /**
1995
     * Returns if the facet count should be calculated based on the facet selection when
1996
     * plugin.tx_solr.search.faceting.keepAllFacetsOnSelection has been enabled
1997
     *
1998
     * plugin.tx_solr.search.faceting.countAllFacetsForSelection
1999
     *
2000
     * @param bool $defaultIfEmpty
2001
     * @return bool
2002
     */
2003 2
    public function getSearchFacetingCountAllFacetsForSelection($defaultIfEmpty = false)
2004
    {
2005 2
        $countAllFacetsForSelection = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.countAllFacetsForSelection', $defaultIfEmpty);
2006 2
        return $this->getBool($countAllFacetsForSelection);
2007
    }
2008
2009
    /**
2010
     * Returns the configured faceting configuration.
2011
     *
2012
     * plugin.tx_solr.search.faceting.facets
2013
     *
2014
     * @param array $defaultIfEmpty
2015
     * @return array
2016
     */
2017 71
    public function getSearchFacetingFacets(array $defaultIfEmpty = [])
2018
    {
2019 71
        return $this->getObjectByPathOrDefault('plugin.tx_solr.search.faceting.facets.', $defaultIfEmpty);
2020
    }
2021
2022
    /**
2023
     * Returns the configuration of a single facet by facet name.
2024
     *
2025
     * plugin.tx_solr.search.faceting.facets.<facetName>
2026
     *
2027
     * @param string $facetName
2028
     * @param array $defaultIfEmpty
2029
     * @return array
2030
     */
2031 42
    public function getSearchFacetingFacetByName($facetName, $defaultIfEmpty = [])
2032
    {
2033 42
        return $this->getObjectByPathOrDefault('plugin.tx_solr.search.faceting.facets.' . $facetName . '.', $defaultIfEmpty);
2034
    }
2035
2036
    /**
2037
     * Indicates if statistics is enabled or not.
2038
     *
2039
     * plugin.tx_solr.statistics
2040
     *
2041
     * @param bool $defaultIfEmpty
2042
     * @return bool
2043
     */
2044 38
    public function getStatistics($defaultIfEmpty = false)
2045
    {
2046 38
        $isStatisticsEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.statistics', $defaultIfEmpty);
2047 38
        return $this->getBool($isStatisticsEnabled);
2048
    }
2049
2050
    /**
2051
     * Indicates to which length an ip should be anonymized in the statistics
2052
     *
2053
     * plugin.tx_solr.statistics.anonymizeIP
2054
     *
2055
     * @param int $defaultIfEmpty
2056
     * @return int
2057
     */
2058 27
    public function getStatisticsAnonymizeIP($defaultIfEmpty = 0)
2059
    {
2060 27
        $anonymizeToLength = $this->getValueByPathOrDefaultValue('plugin.tx_solr.statistics.anonymizeIP', $defaultIfEmpty);
2061 27
        return (int)$anonymizeToLength;
2062
    }
2063
2064
    /**
2065
     * Indicates if additional debug Data should be added to the statistics
2066
     *
2067
     * plugin.tx_solr.statistics.addDebugData
2068
     *
2069
     * @param bool $defaultIfEmpty
2070
     * @return bool
2071
     */
2072 33
    public function getStatisticsAddDebugData($defaultIfEmpty = false)
2073
    {
2074 33
        $statisticsAddDebugDataEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.statistics.addDebugData', $defaultIfEmpty);
2075 33
        return $this->getBool($statisticsAddDebugDataEnabled);
2076
    }
2077
2078
    /**
2079
     * Indicates if suggestion is enabled or not.
2080
     *
2081
     * plugin.tx_solr.suggest
2082
     *
2083
     * @param bool $defaultIfEmpty
2084
     * @return bool
2085
     */
2086
    public function getSuggest($defaultIfEmpty = false)
2087
    {
2088
        $isSuggestionEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest', $defaultIfEmpty);
2089
        return $this->getBool($isSuggestionEnabled);
2090
    }
2091
2092
    /**
2093
     * Indicates if https should be used for the suggest form.
2094
     *
2095
     * plugin.tx_solr.suggest.forceHttps
2096
     *
2097
     * @param bool $defaultIfEmpty
2098
     * @return bool
2099
     */
2100
    public function getSuggestForceHttps($defaultIfEmpty = false)
2101
    {
2102
        $isHttpsForced = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest.forceHttps', $defaultIfEmpty);
2103
        return $this->getBool($isHttpsForced);
2104
    }
2105
2106
    /**
2107
     * Returns the allowed number of suggestions.
2108
     *
2109
     * plugin.tx_solr.suggest.numberOfSuggestions
2110
     *
2111
     * @param int $defaultIfEmpty
2112
     * @return int
2113
     */
2114
    public function getSuggestNumberOfSuggestions($defaultIfEmpty = 10)
2115
    {
2116
        $numberOfSuggestions = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest.numberOfSuggestions', $defaultIfEmpty);
2117
        return (int)$numberOfSuggestions;
2118
    }
2119
2120
    /**
2121
     * Indicates if the topResults should be shown or not
2122
     *
2123
     * plugin.tx_solr.suggest.showTopResults
2124
     *
2125
     * @param bool $defaultIfEmpty
2126
     * @return bool
2127
     */
2128
    public function getSuggestShowTopResults($defaultIfEmpty = true)
2129
    {
2130
        $showTopResults = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest.showTopResults', $defaultIfEmpty);
2131
        return $this->getBool($showTopResults);
2132
    }
2133
2134
    /**
2135
     * Returns the configured number of top results to show
2136
     *
2137
     * plugin.tx_solr.suggest.numberOfTopResults
2138
     *
2139
     * @param int $defaultIfEmpty
2140
     * @return int
2141
     */
2142
    public function getSuggestNumberOfTopResults($defaultIfEmpty = 5)
2143
    {
2144
        $numberOfTopResults = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest.numberOfTopResults', $defaultIfEmpty);
2145
        return (int)$numberOfTopResults;
2146
    }
2147
2148
    /**
2149
     * Returns the configured template for a specific template fileKey.
2150
     *
2151
     * plugin.tx_solr.view.templateFiles.<fileKey>
2152
     *
2153
     * @param string $fileKey
2154
     * @param string $defaultIfEmpty
2155
     * @return string
2156
     */
2157 41
    public function getViewTemplateByFileKey($fileKey, $defaultIfEmpty = '')
2158
    {
2159 41
        $templateFileName = $this->getValueByPathOrDefaultValue('plugin.tx_solr.view.templateFiles.' . $fileKey, $defaultIfEmpty);
2160 41
        return (string)$templateFileName;
2161
    }
2162
2163
    /**
2164
     * Returns the configured available template files for the flexform.
2165
     *
2166
     * plugin.tx_solr.view.templateFiles.[fileKey].availableTemplates.
2167
     *
2168
     * @param string $fileKey
2169
     * @return array
2170
     */
2171
    public function getAvailableTemplatesByFileKey($fileKey)
2172
    {
2173
        $path = 'plugin.tx_solr.view.templateFiles.' . $fileKey . '.availableTemplates.';
2174
        return (array)$this->getObjectByPathOrDefault($path, []);
2175
    }
2176
2177
    /**
2178
     * Returns the configuration of the crop view helper.
2179
     *
2180
     * plugin.tx_solr.viewHelpers.crop.
2181
     *
2182
     * @param array $defaultIfEmpty
2183
     * @return array
2184
     */
2185
    public function getViewHelpersCropConfiguration(array $defaultIfEmpty = [])
2186
    {
2187
        $cropViewHelperConfiguration = $this->getObjectByPathOrDefault('plugin.tx_solr.viewHelpers.crop.', $defaultIfEmpty);
2188
        return $cropViewHelperConfiguration;
2189
    }
2190
2191
    /**
2192
     * Returns the configuration of the sorting view helper.
2193
     *
2194
     * plugin.tx_solr.viewHelpers.sortIndicator.
2195
     *
2196
     * @param array $defaultIfEmpty
2197
     * @return array
2198
     */
2199
    public function getViewHelpersSortIndicatorConfiguration(array $defaultIfEmpty = [])
2200
    {
2201
        $sortingViewHelperConfiguration = $this->getObjectByPathOrDefault('plugin.tx_solr.viewHelpers.sortIndicator.', $defaultIfEmpty);
2202
        return $sortingViewHelperConfiguration;
2203
    }
2204
2205
    /**
2206
     * Controls whether ext-solr will send commits to solr.
2207
     * Beware: If you disable this, you need to ensure
2208
     * that some other mechanism will commit your changes
2209
     * otherwise they will never be searchable.
2210
     * A good way to achieve this is enabling the solr
2211
     * daemons autoCommit feature.
2212
     *
2213
     * plugin.tx_solr.index.enableCommits
2214
     *
2215
     * @param bool $defaultIfEmpty
2216
     * @return bool
2217
     */
2218 16
    public function getEnableCommits($defaultIfEmpty = true)
2219
    {
2220 16
        $enableCommits = $this->getValueByPathOrDefaultValue('plugin.tx_solr.index.enableCommits', $defaultIfEmpty);
2221 16
        return $this->getBool($enableCommits);
2222
    }
2223
2224
    /**
2225
     * Returns the url namespace that is used for the arguments.
2226
     *
2227
     * plugin.tx_solr.view.pluginNamespace
2228
     *
2229
     * @param string $defaultIfEmpty
2230
     * @return string
2231
     */
2232 42
    public function getSearchPluginNamespace($defaultIfEmpty = 'tx_solr')
2233
    {
2234 42
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.view.pluginNamespace', $defaultIfEmpty);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...pace', $defaultIfEmpty) also could return the type array which is incompatible with the documented return type string.
Loading history...
2235
    }
2236
2237
    /**
2238
     * Returns true if the global url parameter q, that indicates the query should be used.
2239
     *
2240
     * Should be set to false, when multiple instance on the same page should have their querystring.
2241
     *
2242
     * plugin.tx_solr.search.ignoreGlobalQParameter
2243
     *
2244
     * @param bool $defaultIfEmpty
2245
     * @return bool
2246
     */
2247 29
    public function getSearchIgnoreGlobalQParameter($defaultIfEmpty = false)
2248
    {
2249 29
        $enableQParameter = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.ignoreGlobalQParameter', $defaultIfEmpty);
2250 29
        return $this->getBool($enableQParameter);
2251
2252
    }
2253
2254
    /**
2255
     * Method to check if grouping was enabled with typoscript.
2256
     *
2257
     * plugin.tx_solr.search.grouping
2258
     *
2259
     * @param bool $defaultIfEmpty
2260
     * @return bool
2261
     */
2262 124
    public function getSearchGrouping($defaultIfEmpty = false)
2263
    {
2264 124
        $groupingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.grouping', $defaultIfEmpty);
2265 124
        return $this->getBool($groupingEnabled);
2266
    }
2267
2268
    /**
2269
     * Returns the configured numberOfGroups.
2270
     *
2271
     * plugin.tx_solr.search.grouping.numberOfGroups
2272
     *
2273
     * @param int $defaultIfEmpty
2274
     * @return int
2275
     */
2276
    public function getSearchGroupingNumberOfGroups($defaultIfEmpty = 5)
2277
    {
2278
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.grouping.numberOfGroups', $defaultIfEmpty);
2279
    }
2280
2281
    /**
2282
     * Returns the highestValue of the numberOfResultsPerGroup configuration that is globally configured and
2283
     * for each group.
2284
     *
2285
     * plugin.tx_solr.search.grouping.
2286
     *
2287
     * @param int $defaultIfEmpty
2288
     * @return int
2289
     */
2290 2
    public function getSearchGroupingHighestGroupResultsLimit($defaultIfEmpty = 1)
2291
    {
2292 2
        $groupingConfiguration = $this->getObjectByPathOrDefault('plugin.tx_solr.search.grouping.', []);
2293 2
        $highestLimit = $defaultIfEmpty;
2294 2
        if (!empty($groupingConfiguration['numberOfResultsPerGroup'])) {
2295 2
            $highestLimit = $groupingConfiguration['numberOfResultsPerGroup'];
2296
        }
2297
2298 2
        $configuredGroups = $groupingConfiguration['groups.'];
2299 2
        if (!is_array($configuredGroups)) {
2300
            return $highestLimit;
2301
        }
2302
2303 2
        foreach ($configuredGroups as $groupName => $groupConfiguration) {
2304 2
            if (!empty($groupConfiguration['numberOfResultsPerGroup']) && $groupConfiguration['numberOfResultsPerGroup'] > $highestLimit) {
2305 2
                $highestLimit = $groupConfiguration['numberOfResultsPerGroup'];
2306
            }
2307
        }
2308
2309 2
        return $highestLimit;
2310
    }
2311
2312
    /**
2313
     * Returns the valid numberOfResultsPerGroup value for a group.
2314
     *
2315
     * Returns:
2316
     *
2317
     * plugin.tx_solr.search.grouping.groups.<groupName>.numberOfResultsPerGroup if it is set otherwise
2318
     * plugin.tx_solr.search.grouping.numberOfResultsPerGroup
2319
     *
2320
     * @param string $groupName
2321
     * @param int $defaultIfEmpty
2322
     * @return int
2323
     */
2324
    public function getSearchGroupingResultLimit($groupName, $defaultIfEmpty = 1)
2325
    {
2326
        $specificPath = 'plugin.tx_solr.search.grouping.groups.' . $groupName . 'numberOfResultsPerGroup';
2327
        $specificResultsPerGroup = $this->getValueByPathOrDefaultValue($specificPath, null);
2328
2329
        if ($specificResultsPerGroup !== null) {
2330
            return (int) $specificResultsPerGroup;
2331
        }
2332
2333
        $commonPath = 'plugin.tx_solr.search.grouping.numberOfResultsPerGroup';
2334
        $commonValue = $this->getValueByPathOrDefaultValue($commonPath, null);
2335
        if ($commonValue !== null) {
2336
            return (int) $commonValue;
2337
        }
2338
2339
        return $defaultIfEmpty;
2340
    }
2341
2342
    /**
2343
     * Returns everything that is configured for the groups (plugin.tx_solr.search.grouping.groups.)
2344
     *
2345
     * plugin.tx_solr.search.grouping.groups.
2346
     *
2347
     * @param array $defaultIfEmpty
2348
     * @return array
2349
     */
2350
    public function getSearchGroupingGroupsConfiguration($defaultIfEmpty = [])
2351
    {
2352
        return $this->getObjectByPathOrDefault('plugin.tx_solr.search.grouping.groups.', $defaultIfEmpty);
2353
    }
2354
2355
    /*
2356
     * Applies the stdWrap if it is configured for the path, otherwise the unprocessed value will be returned.
2357
     *
2358
     * @param string $valuePath
2359
     * @param mixed $value
2360
     * @return mixed
2361
     */
2362 7
    protected function renderContentElementOfConfigured($valuePath, $value)
2363
    {
2364 7
        $configurationPath = $valuePath . '.';
2365 7
        $configuration = $this->getObjectByPath($configurationPath);
2366
2367 7
        if ($configuration == null) {
0 ignored issues
show
introduced by
The condition $configuration == null can never be true.
Loading history...
2368 5
            return $value;
2369
        }
2370
2371 2
        return $this->contentObjectService->renderSingleContentObject($value, $configuration);
2372
    }
2373
}
2374