Passed
Pull Request — master (#2705)
by Rafael
07:35
created

getSearchFacetingUrlParameterSort()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
namespace ApacheSolrForTypo3\Solr\System\Configuration;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
use ApacheSolrForTypo3\Solr\IndexQueue\Indexer;
18
use ApacheSolrForTypo3\Solr\IndexQueue\Initializer\Record;
19
use ApacheSolrForTypo3\Solr\System\ContentObject\ContentObjectService;
20
use ApacheSolrForTypo3\Solr\System\Util\ArrayAccessor;
21
use InvalidArgumentException;
22
use TYPO3\CMS\Core\Utility\ArrayUtility;
23
use TYPO3\CMS\Core\Utility\GeneralUtility;
24
25
/**
26
 * TypoScript configuration object, used to read all TypoScript configuration.
27
 *
28
 * The TypoScriptConfiguration was introduced in order to be able to replace the old,
29
 * array based configuration with one configuration object.
30
 *
31
 * To read the configuration, you should use
32
 *
33
 * $configuration->getValueByPath
34
 *
35
 * or
36
 *
37
 * $configuration->isValidPath
38
 *
39
 * to check if an configuration path exists.
40
 *
41
 * To ensure Backwards compatibility the TypoScriptConfiguration object implements the
42
 * ArrayAccess interface (offsetGet,offsetExists,offsetUnset and offsetSet)
43
 *
44
 * This was only introduced to be backwards compatible in logTerm only "getValueByPath", "isValidPath" or
45
 * speaking methods for configuration settings should be used!
46
 *
47
 * @author Marc Bastian Heinrichs <[email protected]>
48
 * @author Timo Schmidt <[email protected]>
49
 * @copyright (c) 2016 Timo Schmidt <[email protected]>
50
 */
51
class TypoScriptConfiguration
52
{
53
    /**
54
     * @var \ApacheSolrForTypo3\Solr\System\Util\ArrayAccessor|null
55
     */
56
    protected $configurationAccess = null;
57
58
    /**
59
     * Holds the pageId in which context the configuration was parsed
60
     * (normally $GLOBALS['TSFE']->id)
61
     */
62
    protected $contextPageId = 0;
63
64
    /**
65
     * @var ContentObjectService
66
     */
67
    protected $contentObjectService = null;
68
69
    /**
70
     * @param array $configuration
71
     * @param int $contextPageId
72
     * @param ContentObjectService $contentObjectService
73
     */
74 201
    public function __construct(array $configuration, $contextPageId = 0, ContentObjectService $contentObjectService = null)
75
    {
76 201
        $this->configurationAccess = new ArrayAccessor($configuration, '.', true);
77 201
        $this->contextPageId = $contextPageId;
78 201
        $this->contentObjectService = $contentObjectService;
79 201
    }
80
81
    /**
82
     * Checks if a value is 1, '1', 'true'
83
     * @param mixed $value
84
     * @return bool
85
     */
86 162
    protected function getBool($value)
87
    {
88 162
        return filter_var($value, FILTER_VALIDATE_BOOLEAN);
89
    }
90
91
    /**
92
     * This method can be used to only retrieve array keys where the value is not an array.
93
     *
94
     * This can be very handy in the configuration when only keys should ne taken into account
95
     * where the value is not a subconfiguration (typically an typoscript object path).
96
     *
97
     * @param $inputArray
98
     * @return array
99
     */
100 70
    protected function getOnlyArrayKeysWhereValueIsNotAnArray($inputArray)
101
    {
102 70
        $keysWithNonArrayValue = [];
103
104 70
        foreach ($inputArray as $key => $value) {
105 49
            if (is_array($value)) {
106
                // configuration for a content object, skipping
107 43
                continue;
108
            }
109
110 49
            $keysWithNonArrayValue[] = $key;
111
        }
112
113 70
        return $keysWithNonArrayValue;
114
    }
115
116
    /**
117
     * Gets the value from a given TypoScript path.
118
     *
119
     * In the context of an frontend content element the path plugin.tx_solr is
120
     * merged recursive with overrule with the content element specific typoscript
121
     * settings, like plugin.tx_solr_PiResults_Results, and possible flex form settings
122
     * (depends on the solr plugin).
123
     *
124
     * Example: plugin.tx_solr.search.targetPage
125
     * returns $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['search.']['targetPage']
126
     *
127
     * @param string $path TypoScript path
128
     * @return mixed The TypoScript object defined by the given path
129
     * @throws InvalidArgumentException
130
     */
131 167
    public function getValueByPath($path)
132
    {
133 167
        if (!is_string($path)) {
0 ignored issues
show
introduced by
The condition is_string($path) is always true.
Loading history...
134
            throw new InvalidArgumentException('Parameter $path is not a string',
135
                1325623321);
136
        }
137 167
        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

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

341
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
342 38
            return $defaultIfEmpty;
343
        }
344
345 7
        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

345
        return GeneralUtility::trimExplode(',', /** @scrutinizer ignore-type */ $result);
Loading history...
346
    }
347
348
    /**
349
     * Returns an array of all allowedPageTypes.
350
     *
351
     * plugin.tx_solr.index.queue.pages.allowedPageTypes
352
     *
353
     * @param string $configurationName The configuration name of the queue to use.
354
     * @param array $defaultIfEmpty
355
     * @return array
356
     */
357 32
    public function getIndexQueueAllowedPageTypesArrayByConfigurationName($configurationName = 'pages', $defaultIfEmpty = [])
358
    {
359 32
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.allowedPageTypes';
360 32
        $result = $this->getValueByPathOrDefaultValue($path, '');
361 32
        if (trim($result) === '') {
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array; however, parameter $string 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

361
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
362
            return $defaultIfEmpty;
363
        }
364
365 32
        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

365
        return GeneralUtility::trimExplode(',', /** @scrutinizer ignore-type */ $result);
Loading history...
366
    }
367
368
    /**
369
     * Returns the configured excludeContentByClass patterns as array.
370
     *
371
     * plugin.tx_solr.index.queue.pages.excludeContentByClass
372
     *
373
     * @param array $defaultIfEmpty
374
     * @return array
375
     */
376 52
    public function getIndexQueuePagesExcludeContentByClassArray($defaultIfEmpty = [])
377
    {
378 52
        $path = 'plugin.tx_solr.index.queue.pages.excludeContentByClass';
379 52
        $result = $this->getValueByPathOrDefaultValue($path, '');
380
381 52
        if (trim($result) === '') {
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array; however, parameter $string 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

381
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
382 7
            return $defaultIfEmpty;
383
        }
384
385 45
        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

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

554
        if (trim(/** @scrutinizer ignore-type */ $recursiveUpdateFieldsString) === '') {
Loading history...
555 20
            return $defaultIfEmpty;
556
        }
557 6
        $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

557
        $recursiveUpdateFields = GeneralUtility::trimExplode(',', /** @scrutinizer ignore-type */ $recursiveUpdateFieldsString);
Loading history...
558
        // For easier check later on we return an array by combining $recursiveUpdateFields
559 6
        return array_combine($recursiveUpdateFields, $recursiveUpdateFields);
560
    }
561
562
563
    /**
564
     * Retrieves and initialPagesAdditionalWhereClause where clause when configured or an empty string.
565
     *
566
     * plugin.tx_solr.index.queue.<configurationName>.initialPagesAdditionalWhereClause
567
     *
568
     * @param string $configurationName
569
     * @return string
570
     */
571 12
    public function getInitialPagesAdditionalWhereClause($configurationName)
572
    {
573 12
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.initialPagesAdditionalWhereClause';
574 12
        $initialPagesAdditionalWhereClause = $this->getValueByPathOrDefaultValue($path, '');
575
576 12
        if (trim($initialPagesAdditionalWhereClause) === '') {
0 ignored issues
show
Bug introduced by
It seems like $initialPagesAdditionalWhereClause can also be of type array; however, parameter $string 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

576
        if (trim(/** @scrutinizer ignore-type */ $initialPagesAdditionalWhereClause) === '') {
Loading history...
577 12
            return '';
578
        }
579
580
        return trim($initialPagesAdditionalWhereClause);
581
    }
582
583
    /**
584
     * Retrieves and additional where clause when configured or an empty string.
585
     *
586
     * plugin.tx_solr.index.queue.<configurationName>.additionalWhereClause
587
     *
588
     * @param string $configurationName
589
     * @return string
590
     */
591 75
    public function getIndexQueueAdditionalWhereClauseByConfigurationName($configurationName)
592
    {
593 75
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.additionalWhereClause';
594 75
        $additionalWhere = $this->getValueByPathOrDefaultValue($path, '');
595
596 75
        if (trim($additionalWhere) === '') {
0 ignored issues
show
Bug introduced by
It seems like $additionalWhere can also be of type array; however, parameter $string 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

596
        if (trim(/** @scrutinizer ignore-type */ $additionalWhere) === '') {
Loading history...
597 26
            return '';
598
        }
599
600 50
        return ' AND ' . $additionalWhere;
0 ignored issues
show
Bug introduced by
Are you sure $additionalWhere of type array|string 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

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

1237
            return mb_strtolower(/** @scrutinizer ignore-type */ $specificSortOrder);
Loading history...
1238
        }
1239
1240
        // no specific setting, check common setting
1241 34
        $commonPath = 'plugin.tx_solr.search.sorting.defaultOrder';
1242 34
        $commonATagParamOrDefaultValue = $this->getValueByPathOrDefaultValue($commonPath, $defaultIfEmpty);
1243 34
        return mb_strtolower($commonATagParamOrDefaultValue);
1244
    }
1245
1246
    /**
1247
     * Returns the trusted fields configured for the search that do not need to be escaped.
1248
     *
1249
     * @param array $defaultIfEmpty
1250
     * @return array
1251
     */
1252 41
    public function getSearchTrustedFieldsArray($defaultIfEmpty = ['url'])
1253
    {
1254 41
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.trustedFields', '');
1255
1256 41
        if (trim($result) === '') {
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array; however, parameter $string 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

1256
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
1257
            return $defaultIfEmpty;
1258
        }
1259
1260 41
        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

1260
        return GeneralUtility::trimExplode(',', /** @scrutinizer ignore-type */ $result);
Loading history...
1261
    }
1262
1263
    /**
1264
     * Indicates if the plugin arguments should be kept in the search form for a second submission.
1265
     *
1266
     * plugin.tx_solr.search.keepExistingParametersForNewSearches
1267
     *
1268
     * @param bool $defaultIfEmpty
1269
     * @return bool
1270
     */
1271 36
    public function getSearchKeepExistingParametersForNewSearches($defaultIfEmpty = false)
1272
    {
1273 36
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.keepExistingParametersForNewSearches', $defaultIfEmpty);
1274 36
        return $this->getBool($result);
1275
    }
1276
1277
    /**
1278
     * Returns if an empty query is allowed on the query level.
1279
     *
1280
     * plugin.tx_solr.search.query.allowEmptyQuery
1281
     *
1282
     * @param string $defaultIfEmpty
1283
     * @return bool
1284
     */
1285 39
    public function getSearchQueryAllowEmptyQuery($defaultIfEmpty = '')
1286
    {
1287 39
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.allowEmptyQuery', $defaultIfEmpty);
1288 39
        return $this->getBool($result);
1289
    }
1290
1291
    /**
1292
     * Returns the filter configuration array
1293
     *
1294
     * plugin.tx_solr.search.query.filter.
1295
     *
1296
     * @param array $defaultIfEmpty
1297
     * @return array
1298
     */
1299 42
    public function getSearchQueryFilterConfiguration(array $defaultIfEmpty = [])
1300
    {
1301 42
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.query.filter.', $defaultIfEmpty);
1302 42
        return $result;
1303
    }
1304
1305
    /**
1306
     * Can be used to overwrite the filterConfiguration.
1307
     *
1308
     * plugin.tx_solr.search.query.filter.
1309
     *
1310
     * @param array $configuration
1311
     */
1312
    public function setSearchQueryFilterConfiguration(array $configuration)
1313
    {
1314
        $this->configurationAccess->set('plugin.tx_solr.search.query.filter.', $configuration);
1315
    }
1316
1317
    /**
1318
     * Removes the pageSections filter setting.
1319
     *
1320
     * @return void
1321
     */
1322 1
    public function removeSearchQueryFilterForPageSections()
1323
    {
1324 1
        $this->configurationAccess->reset('plugin.tx_solr.search.query.filter.__pageSections');
1325 1
    }
1326
1327
    /**
1328
     * Returns the configured queryFields from TypoScript
1329
     *
1330
     * plugin.tx_solr.search.query.queryFields
1331
     *
1332
     * @param string $defaultIfEmpty
1333
     * @return string
1334
     */
1335 42
    public function getSearchQueryQueryFields($defaultIfEmpty = '')
1336
    {
1337 42
        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...
1338
    }
1339
1340
    /**
1341
     * This method is used to check if a phrase search is enabled or not
1342
     *
1343
     * plugin.tx_solr.search.query.phrase = 1
1344
     *
1345
     * @param bool $defaultIfEmpty
1346
     * @return bool
1347
     */
1348 42
    public function getPhraseSearchIsEnabled(bool $defaultIfEmpty = false)
1349
    {
1350 42
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.phrase', $defaultIfEmpty);
1351 42
        return $this->getBool($result);
1352
    }
1353
1354
    /**
1355
     * Returns the configured phrase fields from TypoScript
1356
     *
1357
     * plugin.tx_solr.search.query.phrase.fields
1358
     *
1359
     * @param string $defaultIfEmpty
1360
     * @return string
1361
     */
1362
    public function getSearchQueryPhraseFields(string $defaultIfEmpty = '')
1363
    {
1364
        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...
1365
    }
1366
1367
    /**
1368
     * This method is used to check if a bigram phrase search is enabled or not
1369
     *
1370
     * plugin.tx_solr.search.query.bigramPhrase = 1
1371
     *
1372
     * @param bool $defaultIfEmpty
1373
     * @return bool
1374
     */
1375 42
    public function getBigramPhraseSearchIsEnabled(bool $defaultIfEmpty = false)
1376
    {
1377 42
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.bigramPhrase', $defaultIfEmpty);
1378 42
        return $this->getBool($result);
1379
    }
1380
1381
    /**
1382
     * Returns the configured phrase fields from TypoScript
1383
     *
1384
     * plugin.tx_solr.search.query.bigramPhrase.fields
1385
     *
1386
     * @param string $defaultIfEmpty
1387
     * @return string
1388
     */
1389
    public function getSearchQueryBigramPhraseFields(string $defaultIfEmpty = '')
1390
    {
1391
        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...
1392
    }
1393
1394
    /**
1395
     * This method is used to check if a trigram phrase search is enabled or not
1396
     *
1397
     * plugin.tx_solr.search.query.trigramPhrase = 1
1398
     *
1399
     * @param bool $defaultIfEmpty
1400
     * @return bool
1401
     */
1402 42
    public function getTrigramPhraseSearchIsEnabled(bool $defaultIfEmpty = false)
1403
    {
1404 42
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.trigramPhrase', $defaultIfEmpty);
1405 42
        return $this->getBool($result);
1406
    }
1407
1408
    /**
1409
     * Returns the configured trigram phrase fields from TypoScript
1410
     *
1411
     * plugin.tx_solr.search.query.trigramPhrase.fields
1412
     *
1413
     * @param string $defaultIfEmpty
1414
     * @return string
1415
     */
1416
    public function getSearchQueryTrigramPhraseFields(string $defaultIfEmpty = '')
1417
    {
1418
        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...
1419
    }
1420
1421
    /**
1422
     * Returns the configured returnFields as array.
1423
     *
1424
     * plugin.tx_solr.search.query.returnFields
1425
     *
1426
     * @param array $defaultIfEmpty
1427
     * @return array
1428
     */
1429 42
    public function getSearchQueryReturnFieldsAsArray($defaultIfEmpty = [])
1430
    {
1431 42
        $returnFields = $this->getValueByPath('plugin.tx_solr.search.query.returnFields');
1432 42
        if (is_null($returnFields)) {
1433 1
            return $defaultIfEmpty;
1434
        }
1435
1436 41
        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

1436
        return GeneralUtility::trimExplode(',', /** @scrutinizer ignore-type */ $returnFields);
Loading history...
1437
    }
1438
1439
    /**
1440
     * Returns the configured target page for the search.
1441
     * By default the contextPageId will be used
1442
     *
1443
     * plugin.tx_solr.search.targetPage
1444
     *
1445
     * @return int
1446
     */
1447 37
    public function getSearchTargetPage()
1448
    {
1449 37
        $targetPage = (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.targetPage', 0);
1450 37
        if ($targetPage === 0) {
1451
            // when no specific page was configured we use the contextPageId (which is usual $GLOBALS['TSFE']->id)
1452 37
            $targetPage = $this->contextPageId;
1453
        }
1454
1455 37
        return $targetPage;
1456
    }
1457
1458
    /**
1459
     * Retrieves the targetPage configuration.
1460
     *
1461
     * plugin.tx_solr.search.targetPage.
1462
     *
1463
     * @param array $defaultIfEmpty
1464
     * @return array
1465
     */
1466
    public function getSearchTargetPageConfiguration(array $defaultIfEmpty = [])
1467
    {
1468
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.targetPage.', $defaultIfEmpty);
1469
        return $result;
1470
    }
1471
1472
    /**
1473
     * Method to check if the site highlighting is enabled. When the siteHighlighting is enabled the
1474
     * sword_list parameter is added to the results link.
1475
     *
1476
     * plugin.tx_solr.searcb.results.siteHighlighting
1477
     *
1478
     * @param bool $defaultIfEmpty
1479
     * @return bool
1480
     */
1481 28
    public function getSearchResultsSiteHighlighting($defaultIfEmpty = true)
1482
    {
1483 28
        $isSiteHightlightingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.siteHighlighting', $defaultIfEmpty);
1484 28
        return $this->getBool($isSiteHightlightingEnabled);
1485
    }
1486
1487
1488
    /**
1489
     * Can be used to check if the highlighting is enabled
1490
     *
1491
     * plugin.tx_solr.search.results.resultsHighlighting
1492
     *
1493
     * @param boolean $defaultIfEmpty
1494
     * @return boolean
1495
     */
1496 42
    public function getSearchResultsHighlighting($defaultIfEmpty = false)
1497
    {
1498 42
        $isHighlightingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsHighlighting', $defaultIfEmpty);
1499 42
        return $this->getBool($isHighlightingEnabled);
1500
    }
1501
1502
    /**
1503
     * Returns the result highlighting fields.
1504
     *
1505
     * plugin.tx_solr.search.results.resultsHighlighting.highlightFields
1506
     *
1507
     * @param string $defaultIfEmpty
1508
     * @return string
1509
     */
1510 41
    public function getSearchResultsHighlightingFields($defaultIfEmpty = '')
1511
    {
1512 41
        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...
1513
    }
1514
1515
    /**
1516
     * Returns the result highlighting fields as array.
1517
     *
1518
     * plugin.tx_solr.search.results.resultsHighlighting.highlightFields
1519
     *
1520
     * @param array $defaultIfEmpty
1521
     * @return array
1522
     */
1523
    public function getSearchResultsHighlightingFieldsAsArray($defaultIfEmpty = [])
1524
    {
1525
        $highlightingFields = $this->getSearchResultsHighlightingFields('');
1526
1527
        if ($highlightingFields === '') {
1528
            return $defaultIfEmpty;
1529
        }
1530
1531
        return GeneralUtility::trimExplode(',', $highlightingFields, true);
1532
    }
1533
1534
    /**
1535
     * Returns the fragmentSize for highlighted segments.
1536
     *
1537
     * plugin.tx_solr.search.results.resultsHighlighting.fragmentSize
1538
     *
1539
     * @param int $defaultIfEmpty
1540
     * @return int
1541
     */
1542 41
    public function getSearchResultsHighlightingFragmentSize($defaultIfEmpty = 200)
1543
    {
1544 41
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsHighlighting.fragmentSize', $defaultIfEmpty);
1545
    }
1546
1547
    /**
1548
     * Returns the fragmentSeparator for highlighted segments.
1549
     *
1550
     * plugin.tx_solr.search.results.resultsHighlighting.fragmentSeparator
1551
     *
1552
     * @param string $defaultIfEmpty
1553
     * @return string
1554
     */
1555 28
    public function getSearchResultsHighlightingFragmentSeparator($defaultIfEmpty = '[...]')
1556
    {
1557 28
        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...
1558
    }
1559
1560
    /**
1561
     * Returns the number of results that should be shown per page.
1562
     *
1563
     * plugin.tx_solr.search.results.resultsPerPage
1564
     *
1565
     * @param int $defaultIfEmpty
1566
     * @return int
1567
     */
1568 36
    public function getSearchResultsPerPage($defaultIfEmpty = 10)
1569
    {
1570 36
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsPerPage', $defaultIfEmpty);
1571
    }
1572
1573
    /**
1574
     * Returns the available options for the per page switch.
1575
     *
1576
     * plugin.tx_solr.search.results.resultsPerPageSwitchOptions
1577
     *
1578
     * @param array $defaultIfEmpty
1579
     * @return array
1580
     */
1581 36
    public function getSearchResultsPerPageSwitchOptionsAsArray($defaultIfEmpty = [])
1582
    {
1583 36
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsPerPageSwitchOptions', '');
1584
1585 36
        if (trim($result) === '') {
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array; however, parameter $string 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

1585
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
1586
            return $defaultIfEmpty;
1587
        }
1588
1589 36
        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

1589
        return GeneralUtility::intExplode(',', /** @scrutinizer ignore-type */ $result, true);
Loading history...
1590
    }
1591
1592
    /**
1593
     * Returns the configured wrap for the resultHighlighting.
1594
     *
1595
     * plugin.tx_solr.search.results.resultsHighlighting.wrap
1596
     *
1597
     * @param string $defaultIfEmpty
1598
     * @return string
1599
     */
1600 41
    public function getSearchResultsHighlightingWrap($defaultIfEmpty = '')
1601
    {
1602 41
        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...
1603
    }
1604
1605
    /**
1606
     * Indicates if spellchecking is enabled or not.
1607
     *
1608
     * plugin.tx_solr.search.spellchecking
1609
     *
1610
     * @param bool $defaultIfEmpty
1611
     * @return bool
1612
     */
1613 35
    public function getSearchSpellchecking($defaultIfEmpty = false)
1614
    {
1615 35
        $isFacetingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking', $defaultIfEmpty);
1616 35
        return $this->getBool($isFacetingEnabled);
1617
    }
1618
1619
    /**
1620
     * Returns the numberOfSuggestionsToTry that should be used for the spellchecking.
1621
     *
1622
     * plugin.tx_solr.search.spellchecking.numberOfSuggestionsToTry
1623
     *
1624
     * @param int $defaultIfEmpty
1625
     * @return int
1626
     */
1627 35
    public function getSearchSpellcheckingNumberOfSuggestionsToTry($defaultIfEmpty = 1)
1628
    {
1629 35
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking.numberOfSuggestionsToTry', $defaultIfEmpty);
1630
    }
1631
1632
    /**
1633
     * Indicates if a second search should be fired from the spellchecking suggestion if no results could be found.
1634
     *
1635
     * plugin.tx_solr.search.spellchecking.searchUsingSpellCheckerSuggestion
1636
     *
1637
     * @param bool $defaultIfEmpty
1638
     * @return bool
1639
     */
1640 41
    public function getSearchSpellcheckingSearchUsingSpellCheckerSuggestion($defaultIfEmpty = false)
1641
    {
1642 41
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking.searchUsingSpellCheckerSuggestion', $defaultIfEmpty);
1643 41
        return $this->getBool($result);
1644
    }
1645
1646
    /**
1647
     * Indicates if faceting is enabled or not.
1648
     *
1649
     * plugin.tx_solr.search.faceting
1650
     *
1651
     * @param bool $defaultIfEmpty
1652
     * @return bool
1653
     */
1654 42
    public function getSearchFaceting($defaultIfEmpty = false)
1655
    {
1656 42
        $isFacetingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting', $defaultIfEmpty);
1657 42
        return $this->getBool($isFacetingEnabled);
1658
    }
1659
1660
    /**
1661
     * Retrieves the showEvenWhenEmpty for a facet by facet name. If nothing specific is configured
1662
     * the global showEmptyFacets with be returned.
1663
     *
1664
     * plugin.tx_solr.search.faceting.facets.<facetName>.showEvenWhenEmpty
1665
     *
1666
     * or
1667
     *
1668
     * plugin.tx_solr.search.faceting.showEmptyFacets
1669
     *
1670
     *
1671
     * @param string $facetName
1672
     * @param bool $defaultIfEmpty
1673
     * @return bool
1674
     */
1675 37
    public function getSearchFacetingShowEmptyFacetsByName($facetName = '', $defaultIfEmpty = false)
1676
    {
1677 37
        $facetSpecificPath = 'plugin.tx_solr.search.faceting.facets.' . $facetName . '.showEvenWhenEmpty';
1678 37
        $specificShowWhenEmpty = $this->getValueByPathOrDefaultValue($facetSpecificPath, null);
1679
1680
        // if we have a concrete setting, use it
1681 37
        if ($specificShowWhenEmpty !== null) {
1682
            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...
1683
        }
1684
1685
        // no specific setting, check common setting
1686 37
        $commonPath = 'plugin.tx_solr.search.faceting.showEmptyFacets';
1687 37
        $commonIfEmptyOrDefaultValue = $this->getValueByPathOrDefaultValue($commonPath, $defaultIfEmpty);
1688 37
        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...
1689
    }
1690
1691
    /**
1692
     * Returns the wrap for the faceting show all link
1693
     *
1694
     * plugin.tx_solr.search.faceting.showAllLink.wrap
1695
     *
1696
     * @param string $defaultIfEmpty
1697
     * @return string
1698
     */
1699
    public function getSearchFacetingShowAllLinkWrap($defaultIfEmpty = '')
1700
    {
1701
        return (string)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.showAllLink.wrap', $defaultIfEmpty);
1702
    }
1703
1704
    /**
1705
     * Returns the link url parameters that should be added to a facet.
1706
     *
1707
     * plugin.tx_solr.search.faceting.facetLinkUrlParameters
1708
     *
1709
     * @param string $defaultIfEmpty
1710
     * @return string
1711
     */
1712 31
    public function getSearchFacetingFacetLinkUrlParameters($defaultIfEmpty = '')
1713
    {
1714 31
        $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 $string 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

1714
        $linkUrlParameters = trim(/** @scrutinizer ignore-type */ $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.facetLinkUrlParameters', $defaultIfEmpty));
Loading history...
1715
1716 31
        return $linkUrlParameters;
1717
    }
1718
1719
    /**
1720
     * Returns if the facetLinkUrlsParameters should be included in the reset link.
1721
     *
1722
     * plugin.tx_solr.search.faceting.facetLinkUrlParameters.useForFacetResetLinkUrl
1723
     *
1724
     * @param bool $defaultIfEmpty
1725
     * @return bool
1726
     */
1727 4
    public function getSearchFacetingFacetLinkUrlParametersUseForFacetResetLinkUrl($defaultIfEmpty = true)
1728
    {
1729 4
        $useForFacetResetLinkUrl = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.facetLinkUrlParameters.useForFacetResetLinkUrl', $defaultIfEmpty);
1730 4
        return $this->getBool($useForFacetResetLinkUrl);
1731
    }
1732
1733
    /**
1734
     * Returns the link url parameters that should be added to a facet as array.
1735
     *
1736
     * plugin.tx_solr.search.faceting.facetLinkUrlParameters
1737
     *
1738
     * @param array $defaultIfEmpty
1739
     * @return array
1740
     */
1741 31
    public function getSearchFacetingFacetLinkUrlParametersAsArray($defaultIfEmpty = [])
1742
    {
1743 31
        $linkUrlParameters = $this->getSearchFacetingFacetLinkUrlParameters();
1744 31
        if ($linkUrlParameters === '') {
1745
            return $defaultIfEmpty;
1746
        }
1747
1748 31
        return GeneralUtility::explodeUrl2Array($linkUrlParameters);
1749
    }
1750
1751
    /**
1752
     * Return the configured minimumCount value for facets.
1753
     *
1754
     * plugin.tx_solr.search.faceting.minimumCount
1755
     *
1756
     * @param int $defaultIfEmpty
1757
     * @return int
1758
     */
1759 36
    public function getSearchFacetingMinimumCount($defaultIfEmpty = 1)
1760
    {
1761 36
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.minimumCount', $defaultIfEmpty);
1762
    }
1763
1764
    /**
1765
     * Return the configured limit value for facets, used for displaying.
1766
     *
1767
     * plugin.tx_solr.search.faceting.limit
1768
     *
1769
     * @param int $defaultIfEmpty
1770
     * @return int
1771
     */
1772
    public function getSearchFacetingLimit($defaultIfEmpty = 10)
1773
    {
1774
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.limit', $defaultIfEmpty);
1775
    }
1776
1777
    /**
1778
     * Return the configured limit value for facets, used for the response.
1779
     *
1780
     * plugin.tx_solr.search.faceting.facetLimit
1781
     *
1782
     * @param int $defaultIfEmpty
1783
     * @return int
1784
     */
1785 36
    public function getSearchFacetingFacetLimit($defaultIfEmpty = 100)
1786
    {
1787 36
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.facetLimit', $defaultIfEmpty);
1788
    }
1789
1790
    /**
1791
     * Return the configured url parameter style value for facets, used for building faceting parameters.
1792
     *
1793
     * plugin.tx_solr.search.faceting.urlParameterStyle
1794
     *
1795
     * @param string $defaultUrlParameterStyle
1796
     * @return string
1797
     */
1798 36
    public function getSearchFacetingUrlParameterStyle(string $defaultUrlParameterStyle = 'index'): string
1799
    {
1800 36
        return (string)$this->getValueByPathOrDefaultValue(
1801
            'plugin.tx_solr.search.faceting.urlParameterStyle',
1802
            $defaultUrlParameterStyle
1803
        );
1804
    }
1805
1806
    /**
1807
     * Return the configuration if the URL parameters should be sorted.
1808
     *
1809
     * plugin.tx_solr.search.faceting.urlParameterSort
1810
     *
1811
     * @param bool $defaultUrlParameterSort
1812
     * @return bool
1813 36
     */
1814
    public function getSearchFacetingUrlParameterSort(bool $defaultUrlParameterSort = false): bool
1815 36
    {
1816 36
        return (bool)$this->getValueByPathOrDefaultValue(
1817
            'plugin.tx_solr.search.faceting.urlParameterSort',
1818
            $defaultUrlParameterSort
1819
        );
1820
    }
1821
1822
    /**
1823
     * Return the configured faceting sortBy value.
1824
     *
1825
     * plugin.tx_solr.search.faceting.sortBy
1826
     *
1827
     * @param string $defaultIfEmpty
1828
     * @return string
1829
     */
1830
    public function getSearchFacetingSortBy($defaultIfEmpty = '')
1831
    {
1832
        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...
1833
    }
1834
1835
    /**
1836
     * Returns if a facets should be kept on selection. Global faceting setting
1837
     * can also be configured on facet level by using
1838
     * (plugin.tx_solr.search.faceting.facets.<fieldName>.keepAllOptionsOnSelection)
1839
     *
1840
     * plugin.tx_solr.search.faceting.keepAllFacetsOnSelection
1841
     *
1842 38
     * @param bool $defaultIfEmpty
1843
     * @return bool
1844 38
     */
1845
    public function getSearchFacetingKeepAllFacetsOnSelection($defaultIfEmpty = false)
1846
    {
1847
        $keepAllOptionsOnSelection = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.keepAllFacetsOnSelection', $defaultIfEmpty);
1848
        return $this->getBool($keepAllOptionsOnSelection);
1849
    }
1850
1851
    /**
1852
     * Returns if the facet count should be calculated based on the facet selection when
1853
     * plugin.tx_solr.search.faceting.keepAllFacetsOnSelection has been enabled
1854
     *
1855
     * plugin.tx_solr.search.faceting.countAllFacetsForSelection
1856 36
     *
1857
     * @param bool $defaultIfEmpty
1858 36
     * @return bool
1859
     */
1860
    public function getSearchFacetingCountAllFacetsForSelection($defaultIfEmpty = false)
1861
    {
1862
        $countAllFacetsForSelection = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.countAllFacetsForSelection', $defaultIfEmpty);
1863
        return $this->getBool($countAllFacetsForSelection);
1864
    }
1865
1866
    /**
1867
     * Returns the configured faceting configuration.
1868
     *
1869 42
     * plugin.tx_solr.search.faceting.facets
1870
     *
1871 42
     * @param array $defaultIfEmpty
1872 42
     * @return array
1873
     */
1874
    public function getSearchFacetingFacets(array $defaultIfEmpty = [])
1875
    {
1876
        return $this->getObjectByPathOrDefault('plugin.tx_solr.search.faceting.facets.', $defaultIfEmpty);
1877
    }
1878
1879
    /**
1880
     * Returns the configuration of a single facet by facet name.
1881
     *
1882
     * plugin.tx_solr.search.faceting.facets.<facetName>
1883 30
     *
1884
     * @param string $facetName
1885 30
     * @param array $defaultIfEmpty
1886 30
     * @return array
1887
     */
1888
    public function getSearchFacetingFacetByName($facetName, $defaultIfEmpty = [])
1889
    {
1890
        return $this->getObjectByPathOrDefault('plugin.tx_solr.search.faceting.facets.' . $facetName . '.', $defaultIfEmpty);
1891
    }
1892
1893
    /**
1894
     * Indicates if statistics is enabled or not.
1895
     *
1896
     * plugin.tx_solr.statistics
1897 35
     *
1898
     * @param bool $defaultIfEmpty
1899 35
     * @return bool
1900 35
     */
1901
    public function getStatistics($defaultIfEmpty = false)
1902
    {
1903
        $isStatisticsEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.statistics', $defaultIfEmpty);
1904
        return $this->getBool($isStatisticsEnabled);
1905
    }
1906
1907
    /**
1908
     * Indicates to which length an ip should be anonymized in the statistics
1909
     *
1910
     * plugin.tx_solr.statistics.anonymizeIP
1911
     *
1912
     * @param int $defaultIfEmpty
1913
     * @return int
1914
     */
1915
    public function getStatisticsAnonymizeIP($defaultIfEmpty = 0)
1916
    {
1917
        $anonymizeToLength = $this->getValueByPathOrDefaultValue('plugin.tx_solr.statistics.anonymizeIP', $defaultIfEmpty);
1918
        return (int)$anonymizeToLength;
1919
    }
1920
1921
    /**
1922
     * Indicates if additional debug Data should be added to the statistics
1923
     *
1924
     * plugin.tx_solr.statistics.addDebugData
1925
     *
1926
     * @param bool $defaultIfEmpty
1927
     * @return bool
1928
     */
1929
    public function getStatisticsAddDebugData($defaultIfEmpty = false)
1930
    {
1931
        $statisticsAddDebugDataEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.statistics.addDebugData', $defaultIfEmpty);
1932
        return $this->getBool($statisticsAddDebugDataEnabled);
1933
    }
1934
1935
    /**
1936
     * Indicates if suggestion is enabled or not.
1937
     *
1938
     * plugin.tx_solr.suggest
1939 2
     *
1940
     * @param bool $defaultIfEmpty
1941 2
     * @return bool
1942 2
     */
1943
    public function getSuggest($defaultIfEmpty = false)
1944
    {
1945
        $isSuggestionEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest', $defaultIfEmpty);
1946
        return $this->getBool($isSuggestionEnabled);
1947
    }
1948
1949
    /**
1950
     * Indicates if https should be used for the suggest form.
1951
     *
1952
     * plugin.tx_solr.suggest.forceHttps
1953 2
     *
1954
     * @param bool $defaultIfEmpty
1955 2
     * @return bool
1956 2
     */
1957
    public function getSuggestForceHttps($defaultIfEmpty = false)
1958
    {
1959
        $isHttpsForced = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest.forceHttps', $defaultIfEmpty);
1960
        return $this->getBool($isHttpsForced);
1961
    }
1962
1963
    /**
1964
     * Returns the allowed number of suggestions.
1965
     *
1966
     * plugin.tx_solr.suggest.numberOfSuggestions
1967 2
     *
1968
     * @param int $defaultIfEmpty
1969 2
     * @return int
1970 2
     */
1971
    public function getSuggestNumberOfSuggestions($defaultIfEmpty = 10)
1972
    {
1973
        $numberOfSuggestions = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest.numberOfSuggestions', $defaultIfEmpty);
1974
        return (int)$numberOfSuggestions;
1975
    }
1976
1977
    /**
1978
     * Indicates if the topResults should be shown or not
1979
     *
1980
     * plugin.tx_solr.suggest.showTopResults
1981 2
     *
1982
     * @param bool $defaultIfEmpty
1983 2
     * @return bool
1984 2
     */
1985 2
    public function getSuggestShowTopResults($defaultIfEmpty = true)
1986
    {
1987
        $showTopResults = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest.showTopResults', $defaultIfEmpty);
1988
        return $this->getBool($showTopResults);
1989
    }
1990
1991
    /**
1992
     * Returns the configured number of top results to show
1993
     *
1994
     * plugin.tx_solr.suggest.numberOfTopResults
1995
     *
1996
     * @param int $defaultIfEmpty
1997
     * @return int
1998
     */
1999
    public function getSuggestNumberOfTopResults($defaultIfEmpty = 5)
2000 42
    {
2001
        $numberOfTopResults = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest.numberOfTopResults', $defaultIfEmpty);
2002 42
        return (int)$numberOfTopResults;
2003 42
    }
2004
2005
    /**
2006
     * Returns additional fields for the top results
2007
     *
2008
     * plugin.tx_solr.suggest.additionalTopResultsFields
2009
     *
2010
     * @param array $defaultIfEmpty
2011
     * @return array
2012
     */
2013
    public function getSuggestAdditionalTopResultsFields($defaultIfEmpty = [])
2014
    {
2015
        $additionalTopResultsFields = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest.additionalTopResultsFields', '');
2016
        if ($additionalTopResultsFields === '') {
2017
            return $defaultIfEmpty;
2018
        }
2019
2020
        return GeneralUtility::trimExplode(',', $additionalTopResultsFields, true);
0 ignored issues
show
Bug introduced by
It seems like $additionalTopResultsFields 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

2020
        return GeneralUtility::trimExplode(',', /** @scrutinizer ignore-type */ $additionalTopResultsFields, true);
Loading history...
2021
    }
2022
2023
    /**
2024
     * Returns the configured template for a specific template fileKey.
2025
     *
2026
     * plugin.tx_solr.view.templateFiles.<fileKey>
2027
     *
2028
     * @param string $fileKey
2029
     * @param string $defaultIfEmpty
2030
     * @return string
2031
     */
2032
    public function getViewTemplateByFileKey($fileKey, $defaultIfEmpty = '')
2033
    {
2034
        $templateFileName = $this->getValueByPathOrDefaultValue('plugin.tx_solr.view.templateFiles.' . $fileKey, $defaultIfEmpty);
2035
        return (string)$templateFileName;
2036
    }
2037
2038
    /**
2039
     * Returns the configured available template files for the flexform.
2040
     *
2041
     * plugin.tx_solr.view.templateFiles.[fileKey].availableTemplates.
2042
     *
2043
     * @param string $fileKey
2044
     * @return array
2045
     */
2046
    public function getAvailableTemplatesByFileKey($fileKey)
2047
    {
2048
        $path = 'plugin.tx_solr.view.templateFiles.' . $fileKey . '.availableTemplates.';
2049
        return (array)$this->getObjectByPathOrDefault($path, []);
2050
    }
2051
2052
    /**
2053
     * Returns the configuration of the crop view helper.
2054
     *
2055
     * plugin.tx_solr.viewHelpers.crop.
2056
     *
2057
     * @param array $defaultIfEmpty
2058
     * @return array
2059
     */
2060
    public function getViewHelpersCropConfiguration(array $defaultIfEmpty = [])
2061 14
    {
2062
        $cropViewHelperConfiguration = $this->getObjectByPathOrDefault('plugin.tx_solr.viewHelpers.crop.', $defaultIfEmpty);
2063 14
        return $cropViewHelperConfiguration;
2064 14
    }
2065
2066
    /**
2067
     * Returns the configuration of the sorting view helper.
2068
     *
2069
     * plugin.tx_solr.viewHelpers.sortIndicator.
2070
     *
2071
     * @param array $defaultIfEmpty
2072
     * @return array
2073
     */
2074
    public function getViewHelpersSortIndicatorConfiguration(array $defaultIfEmpty = [])
2075 46
    {
2076
        $sortingViewHelperConfiguration = $this->getObjectByPathOrDefault('plugin.tx_solr.viewHelpers.sortIndicator.', $defaultIfEmpty);
2077 46
        return $sortingViewHelperConfiguration;
2078
    }
2079
2080
    /**
2081
     * Controls whether ext-solr will send commits to solr.
2082
     * Beware: If you disable this, you need to ensure
2083
     * that some other mechanism will commit your changes
2084
     * otherwise they will never be searchable.
2085
     * A good way to achieve this is enabling the solr
2086
     * daemons autoCommit feature.
2087
     *
2088
     * plugin.tx_solr.index.enableCommits
2089
     *
2090 31
     * @param bool $defaultIfEmpty
2091
     * @return bool
2092 31
     */
2093 31
    public function getEnableCommits($defaultIfEmpty = true)
2094
    {
2095
        $enableCommits = $this->getValueByPathOrDefaultValue('plugin.tx_solr.index.enableCommits', $defaultIfEmpty);
2096
        return $this->getBool($enableCommits);
2097
    }
2098
2099
    /**
2100
     * Returns the url namespace that is used for the arguments.
2101
     *
2102
     * plugin.tx_solr.view.pluginNamespace
2103
     *
2104
     * @param string $defaultIfEmpty
2105 44
     * @return string
2106
     */
2107 44
    public function getSearchPluginNamespace($defaultIfEmpty = 'tx_solr')
2108
    {
2109 44
        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...
2110 44
    }
2111
2112
    /**
2113
     * Returns true if the global url parameter q, that indicates the query should be used.
2114
     *
2115
     * Should be set to false, when multiple instance on the same page should have their querystring.
2116
     *
2117
     * plugin.tx_solr.search.ignoreGlobalQParameter
2118
     *
2119
     * @param bool $defaultIfEmpty
2120
     * @return bool
2121
     */
2122
    public function getSearchIgnoreGlobalQParameter($defaultIfEmpty = false)
2123
    {
2124
        $enableQParameter = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.ignoreGlobalQParameter', $defaultIfEmpty);
2125 42
        return $this->getBool($enableQParameter);
2126
2127 42
    }
2128 42
2129
    /**
2130
     * Returns the argument names, that should be added to the persistent arguments, as array.
2131
     *
2132
     * plugin.tx_solr.search.additionalPersistentArgumentNames
2133
     *
2134
     * @param array $defaultIfEmpty
2135
     * @return array
2136
     */
2137
    public function getSearchAdditionalPersistentArgumentNames($defaultIfEmpty = [])
2138
    {
2139
        $additionalPersistentArgumentNames = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.additionalPersistentArgumentNames', '');
2140
2141
        if ($additionalPersistentArgumentNames === '') {
2142
            return $defaultIfEmpty;
2143
        }
2144
2145
        return GeneralUtility::trimExplode(',', $additionalPersistentArgumentNames, true);
0 ignored issues
show
Bug introduced by
It seems like $additionalPersistentArgumentNames 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

2145
        return GeneralUtility::trimExplode(',', /** @scrutinizer ignore-type */ $additionalPersistentArgumentNames, true);
Loading history...
2146
2147
    }
2148
2149
    /**
2150
     * Method to check if grouping was enabled with typoscript.
2151
     *
2152
     * plugin.tx_solr.search.grouping
2153
     *
2154
     * @param bool $defaultIfEmpty
2155
     * @return bool
2156
     */
2157
    public function getSearchGrouping($defaultIfEmpty = false)
2158
    {
2159
        $groupingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.grouping', $defaultIfEmpty);
2160
        return $this->getBool($groupingEnabled);
2161
    }
2162
2163
    /**
2164
     * Returns the configured numberOfGroups.
2165
     *
2166
     * plugin.tx_solr.search.grouping.numberOfGroups
2167
     *
2168
     * @param int $defaultIfEmpty
2169
     * @return int
2170
     */
2171
    public function getSearchGroupingNumberOfGroups($defaultIfEmpty = 5)
2172
    {
2173
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.grouping.numberOfGroups', $defaultIfEmpty);
2174
    }
2175
2176
    /**
2177
     * Returns the sortBy configuration for the grouping.
2178
     *
2179
     * plugin.tx_solr.search.grouping.sortBy
2180
     *
2181
     * @param string $defaultIfEmpty
2182
     * @return string
2183
     */
2184
    public function getSearchGroupingSortBy($defaultIfEmpty = '')
2185
    {
2186
        return (string)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.grouping.sortBy', $defaultIfEmpty);
2187
    }
2188
2189
    /**
2190
     * Returns the highestValue of the numberOfResultsPerGroup configuration that is globally configured and
2191
     * for each group.
2192
     *
2193
     * plugin.tx_solr.search.grouping.
2194
     *
2195
     * @param int $defaultIfEmpty
2196
     * @return int
2197
     */
2198
    public function getSearchGroupingHighestGroupResultsLimit($defaultIfEmpty = 1)
2199
    {
2200
        $groupingConfiguration = $this->getObjectByPathOrDefault('plugin.tx_solr.search.grouping.', []);
2201
        $highestLimit = $defaultIfEmpty;
2202
        if (!empty($groupingConfiguration['numberOfResultsPerGroup'])) {
2203
            $highestLimit = $groupingConfiguration['numberOfResultsPerGroup'];
2204
        }
2205
2206
        $configuredGroups = $groupingConfiguration['groups.'];
2207
        if (!is_array($configuredGroups)) {
2208
            return $highestLimit;
2209
        }
2210
2211
        foreach ($configuredGroups as $groupName => $groupConfiguration) {
2212
            if (!empty($groupConfiguration['numberOfResultsPerGroup']) && $groupConfiguration['numberOfResultsPerGroup'] > $highestLimit) {
2213
                $highestLimit = $groupConfiguration['numberOfResultsPerGroup'];
2214
            }
2215
        }
2216
2217
        return $highestLimit;
2218
    }
2219
2220
    /**
2221
     * Returns the valid numberOfResultsPerGroup value for a group.
2222
     *
2223
     * Returns:
2224
     *
2225
     * plugin.tx_solr.search.grouping.groups.<groupName>.numberOfResultsPerGroup if it is set otherwise
2226
     * plugin.tx_solr.search.grouping.numberOfResultsPerGroup
2227
     *
2228
     * @param string $groupName
2229
     * @param int $defaultIfEmpty
2230
     * @return int
2231
     */
2232
    public function getSearchGroupingResultLimit($groupName, $defaultIfEmpty = 1)
2233
    {
2234
        $specificPath = 'plugin.tx_solr.search.grouping.groups.' . $groupName . 'numberOfResultsPerGroup';
2235
        $specificResultsPerGroup = $this->getValueByPathOrDefaultValue($specificPath, null);
2236
2237
        if ($specificResultsPerGroup !== null) {
2238
            return (int) $specificResultsPerGroup;
2239
        }
2240
2241
        $commonPath = 'plugin.tx_solr.search.grouping.numberOfResultsPerGroup';
2242
        $commonValue = $this->getValueByPathOrDefaultValue($commonPath, null);
2243
        if ($commonValue !== null) {
2244
            return (int) $commonValue;
2245
        }
2246
2247
        return $defaultIfEmpty;
2248
    }
2249
2250
    /**
2251
     * Returns everything that is configured for the groups (plugin.tx_solr.search.grouping.groups.)
2252
     *
2253
     * plugin.tx_solr.search.grouping.groups.
2254
     *
2255
     * @param array $defaultIfEmpty
2256
     * @return array
2257
     */
2258
    public function getSearchGroupingGroupsConfiguration($defaultIfEmpty = [])
2259
    {
2260
        return $this->getObjectByPathOrDefault('plugin.tx_solr.search.grouping.groups.', $defaultIfEmpty);
2261
    }
2262
2263
    /*
2264
     * Applies the stdWrap if it is configured for the path, otherwise the unprocessed value will be returned.
2265
     *
2266
     * @param string $valuePath
2267
     * @param mixed $value
2268
     * @return mixed
2269
     */
2270
    protected function renderContentElementOfConfigured($valuePath, $value)
2271
    {
2272
        $configurationPath = $valuePath . '.';
2273
        $configuration = $this->getObjectByPath($configurationPath);
2274
2275
        if ($configuration == null) {
2276
            return $value;
2277
        }
2278
        if ($this->contentObjectService === null) {
2279
            $this->contentObjectService = GeneralUtility::makeInstance(ContentObjectService::class);
2280
        }
2281
        return $this->contentObjectService->renderSingleContentObject($value, $configuration);
2282
    }
2283
}
2284