Failed Conditions
Push — task/2976_TYPO3.11_compatibili... ( 14c9f4...2d3a36 )
by Rafael
23:17
created

getSearchFacetingMinimumCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace ApacheSolrForTypo3\Solr\System\Configuration;
4
5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
18
use ApacheSolrForTypo3\Solr\IndexQueue\Indexer;
19
use ApacheSolrForTypo3\Solr\IndexQueue\Initializer\Record;
20
use ApacheSolrForTypo3\Solr\System\ContentObject\ContentObjectService;
21
use ApacheSolrForTypo3\Solr\System\Util\ArrayAccessor;
22
use InvalidArgumentException;
23
use TYPO3\CMS\Core\Utility\ArrayUtility;
24
use TYPO3\CMS\Core\Utility\GeneralUtility;
25
26
/**
27
 * TypoScript configuration object, used to read all TypoScript configuration.
28
 *
29
 * The TypoScriptConfiguration was introduced in order to be able to replace the old,
30
 * array based configuration with one configuration object.
31
 *
32
 * To read the configuration, you should use
33
 *
34
 * $configuration->getValueByPath
35
 *
36
 * or
37
 *
38
 * $configuration->isValidPath
39
 *
40
 * to check if a configuration path exists.
41
 *
42
 * To ensure Backwards compatibility the TypoScriptConfiguration object implements the
43
 * ArrayAccess interface (offsetGet,offsetExists,offsetUnset and offsetSet)
44
 *
45
 * This was only introduced to be backwards compatible in long term only "getValueByPath", "isValidPath" or
46
 * speaking methods for configuration settings should be used!
47
 *
48
 * @author Marc Bastian Heinrichs <[email protected]>
49
 * @author Timo Schmidt <[email protected]>
50
 * @copyright (c) 2016 Timo Schmidt <[email protected]>
51
 */
52
class TypoScriptConfiguration
53
{
54
    /**
55
     * @var ArrayAccessor
56
     */
57
    protected ArrayAccessor $configurationAccess;
58
59
    /**
60
     * Holds the pageId in which context the configuration was parsed
61
     * (normally $GLOBALS['TSFE']->id)
62
     * @var int
63
     */
64
    protected int $contextPageId = 0;
65
66
    /**
67
     * @var ContentObjectService
68
     */
69
    protected ContentObjectService $contentObjectService;
70
71
    /**
72
     * @param array $configuration
73
     * @param int|null $contextPageId
74
     * @param ContentObjectService|null $contentObjectService
75
     */
76 390
    public function __construct(
77
        array $configuration,
78
        int $contextPageId = null,
79
        ContentObjectService $contentObjectService = null
80
    ) {
81 390
        $this->configurationAccess = new ArrayAccessor($configuration, '.', true);
82 390
        $this->contextPageId = $contextPageId ?? 0;
83 390
        $this->contentObjectService = $contentObjectService ?? GeneralUtility::makeInstance(ContentObjectService::class);
84 390
    }
85
86
    /**
87
     * Checks if a value is 1, '1', 'true'
88
     * @param mixed $value
89
     * @return bool
90
     */
91 258
    protected function getBool($value): bool
92
    {
93 258
        return filter_var($value, FILTER_VALIDATE_BOOLEAN);
94
    }
95
96
    /**
97
     * This method can be used to only retrieve array keys where the value is not an array.
98
     *
99
     * This can be very handy in the configuration when only keys should be taken into account
100
     * where the value is not a subconfiguration (typically a typoscript object path).
101
     *
102
     * @param $inputArray
103
     * @return array
104
     */
105 33
    protected function getOnlyArrayKeysWhereValueIsNotAnArray($inputArray): array
106
    {
107 33
        $keysWithNonArrayValue = [];
108
109 33
        foreach ($inputArray as $key => $value) {
110 12
            if (is_array($value)) {
111
                // configuration for a content object, skipping
112 9
                continue;
113
            }
114
115 12
            $keysWithNonArrayValue[] = $key;
116
        }
117
118 33
        return $keysWithNonArrayValue;
119
    }
120
121
    /**
122
     * Gets the value from a given TypoScript path.
123
     *
124
     * In the context of a frontend content element the path plugin.tx_solr is
125
     * merged recursive with overrule with the content element specific typoscript
126
     * settings, like plugin.tx_solr_PiResults_Results, and possible flex form settings
127
     * (depends on the solr plugin).
128
     *
129
     * Example: plugin.tx_solr.search.targetPage
130
     * returns $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['search.']['targetPage']
131
     *
132
     * @param string $path TypoScript path
133
     * @return mixed The TypoScript object defined by the given path
134
     * @throws InvalidArgumentException
135
     */
136 281
    public function getValueByPath(string $path)
137
    {
138 281
        return $this->configurationAccess->get($path);
139
    }
140
141
    /**
142
     * This method can be used to get  a configuration value by path if it exists or return a
143
     * default value when it does not exist.
144
     *
145
     * @param string $path
146
     * @param mixed $defaultValue
147
     * @return mixed
148
     */
149 278
    public function getValueByPathOrDefaultValue(string $path, $defaultValue)
150
    {
151 278
        $value = $this->getValueByPath($path);
152 278
        if (is_null($value)) {
153 265
            return $defaultValue;
154
        }
155
156 152
        return $value;
157
    }
158
159
    /**
160
     * Gets the parent TypoScript Object from a given TypoScript path.
161
     *
162
     * In the context of a frontend content element the path plugin.tx_solr is
163
     * merged recursive with overrule with the content element specific typoscript
164
     * settings, like plugin.tx_solr_PiResults_Results, and possible flex form settings
165
     * (depends on the solr plugin).
166
     *
167
     * Example: plugin.tx_solr.index.queue.tt_news.fields.content
168
     * returns $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['index.']['queue.']['tt_news.']['fields.']['content.']
169
     * which is a SOLR_CONTENT cObj.
170
     *
171
     * @param string $path TypoScript path
172
     * @return mixed The TypoScript object defined by the given path
173
     * @throws InvalidArgumentException
174
     */
175 253
    public function getObjectByPath(string $path)
176
    {
177 253
        if (substr($path, -1) !== '.') {
178 1
            $path = rtrim($path, '.');
179 1
            $path = substr($path, 0, strrpos($path, '.') + 1);
180
        }
181
182 253
        return $this->configurationAccess->get($path);
183
    }
184
185
    /**
186
     * Gets the parent TypoScript Object from a given TypoScript path and if not present return
187
     * the default value
188
     *
189
     * @param string $path
190
     * @param array $defaultValue
191
     * @return array
192
     *@see getObjectByPath
193
     */
194 252
    public function getObjectByPathOrDefault(string $path, array $defaultValue = []): array
195
    {
196
        try {
197 252
            $object = $this->getObjectByPath($path);
198
        } catch (InvalidArgumentException $e) {
199
            return $defaultValue;
200
        }
201
202 252
        if (!is_array($object)) {
203 118
            return $defaultValue;
204
        }
205
206 174
        return $object;
207
    }
208
209
    /**
210
     * Checks whether a given TypoScript path is valid.
211
     *
212
     * @param string $path TypoScript path
213
     * @return bool TRUE if the path resolves, FALSE otherwise
214
     */
215
    public function isValidPath(string $path): bool
216
    {
217
        $isValidPath = false;
218
219
        $pathValue = $this->getValueByPath($path);
220
        if (!is_null($pathValue)) {
221
            $isValidPath = true;
222
        }
223
224
        return $isValidPath;
225
    }
226
227
    /**
228
     * Merges a configuration with another configuration a
229
     *
230
     * @param array $configurationToMerge
231
     * @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.
232
     * @param bool $includeEmptyValues If set, values from $overrule will overrule if they are empty or zero.
233
     * @param bool $enableUnsetFeature If set, special values "__UNSET" can be used in overruled array in order to unset array keys in the original array.
234
     * @return TypoScriptConfiguration
235
     */
236 7
    public function mergeSolrConfiguration(array $configurationToMerge, bool $addKeys = true, bool $includeEmptyValues = true, bool $enableUnsetFeature = true): TypoScriptConfiguration
237
    {
238 7
        $data = $this->configurationAccess->getData();
239 7
        ArrayUtility::mergeRecursiveWithOverrule(
240 7
            $data['plugin.']['tx_solr.'],
241 5
            $configurationToMerge,
242 5
            $addKeys,
243 5
            $includeEmptyValues,
244 5
            $enableUnsetFeature
245
        );
246
247 7
        $this->configurationAccess->setData($data);
248
249 7
        return $this;
250
    }
251
252
    /**
253
     * Returns true when ext_solr is enabled
254
     *
255
     * @param boolean $defaultIfEmpty
256
     * @return boolean
257
     */
258 2
    public function getEnabled(bool $defaultIfEmpty = false): bool
259
    {
260 2
        $path = 'plugin.tx_solr.enabled';
261 2
        $result = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty);
262 2
        return $this->getBool($result);
263
    }
264
265
    /**
266
     * Returns the configured additionalFields configured for the indexing.
267
     *
268
     * plugin.tx_solr.index.additionalFields.
269
     *
270
     * @param array $defaultIfEmpty
271
     * @return array
272
     */
273 33
    public function getIndexAdditionalFieldsConfiguration(array $defaultIfEmpty = []): array
274
    {
275 33
        return $this->getObjectByPathOrDefault('plugin.tx_solr.index.additionalFields.', $defaultIfEmpty);
276
    }
277
278
    /**
279
     * Returns all solr fields names where a mapping is configured in index.additionalFields
280
     *
281
     * Returns all keys from
282
     * plugin.tx_solr.index.additionalFields.
283
     *
284
     * @param array $defaultIfEmpty
285
     * @return array
286
     */
287 32
    public function getIndexMappedAdditionalFieldNames(array $defaultIfEmpty = []): array
288
    {
289 32
        $mappingConfiguration = $this->getIndexAdditionalFieldsConfiguration();
290 32
        $mappedFieldNames = $this->getOnlyArrayKeysWhereValueIsNotAnArray($mappingConfiguration);
291 32
        return count($mappedFieldNames) == 0 ? $defaultIfEmpty : $mappedFieldNames;
292
    }
293
294
    /**
295
     * Returns the fieldProcessingInstructions configuration array
296
     *
297
     * plugin.tx_solr.index.fieldProcessingInstructions.
298
     *
299
     * @param array $defaultIfEmpty
300
     * @return array
301
     */
302 50
    public function getIndexFieldProcessingInstructionsConfiguration(array $defaultIfEmpty = []): array
303
    {
304 50
        return $this->getObjectByPathOrDefault('plugin.tx_solr.index.fieldProcessingInstructions.', $defaultIfEmpty);
305
    }
306
307
    /**
308
     * Retrieves the indexing configuration array for an indexing queue by configuration name.
309
     *
310
     * plugin.tx_solr.index.queue.<configurationName>.
311
     *
312
     * @param string $configurationName
313
     * @param array $defaultIfEmpty
314
     * @return array
315
     */
316 13
    public function getIndexQueueConfigurationByName(string $configurationName, array $defaultIfEmpty = []): array
317
    {
318 13
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.';
319 13
        return $this->getObjectByPathOrDefault($path, $defaultIfEmpty);
320
    }
321
322
    /**
323
     * Returns an array of all additionalPageIds by index configuration name.
324
     *
325
     * plugin.tx_solr.index.queue.pages.additionalPageIds
326
     *
327
     * @param string $configurationName
328
     * @param array $defaultIfEmpty
329
     * @return array
330
     */
331 48
    public function getIndexQueueAdditionalPageIdsByConfigurationName(string $configurationName = 'pages', array $defaultIfEmpty = []): array
332
    {
333 48
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.additionalPageIds';
334 48
        $result = $this->getValueByPathOrDefaultValue($path, '');
335 48
        if (trim($result) === '') {
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array and null; 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

335
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
336 42
            return $defaultIfEmpty;
337
        }
338
339 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

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

355
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
356
            return $defaultIfEmpty;
357
        }
358
359 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

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

375
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
376
            return $defaultIfEmpty;
377
        }
378
379 15
        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

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

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

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

547
        $recursiveUpdateFields = GeneralUtility::trimExplode(',', /** @scrutinizer ignore-type */ $recursiveUpdateFieldsString);
Loading history...
548
        // For easier check later on we return an array by combining $recursiveUpdateFields
549 7
        return array_combine($recursiveUpdateFields, $recursiveUpdateFields);
550
    }
551
552
553
    /**
554
     * Retrieves and initialPagesAdditionalWhereClause where clause when configured or an empty string.
555
     *
556
     * plugin.tx_solr.index.queue.<configurationName>.initialPagesAdditionalWhereClause
557
     *
558
     * @param string $configurationName
559
     * @return string
560
     */
561 13
    public function getInitialPagesAdditionalWhereClause(string $configurationName): string
562
    {
563 13
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.initialPagesAdditionalWhereClause';
564 13
        $initialPagesAdditionalWhereClause = $this->getValueByPathOrDefaultValue($path, '');
565
566 13
        if (trim($initialPagesAdditionalWhereClause) === '') {
0 ignored issues
show
Bug introduced by
It seems like $initialPagesAdditionalWhereClause can also be of type array and null; 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

566
        if (trim(/** @scrutinizer ignore-type */ $initialPagesAdditionalWhereClause) === '') {
Loading history...
567 13
            return '';
568
        }
569
570 1
        return trim($initialPagesAdditionalWhereClause);
571
    }
572
573
    /**
574
     * Retrieves and additional where clause when configured or an empty string.
575
     *
576
     * plugin.tx_solr.index.queue.<configurationName>.additionalWhereClause
577
     *
578
     * @param string $configurationName
579
     * @return string
580
     */
581 67
    public function getIndexQueueAdditionalWhereClauseByConfigurationName(string $configurationName): string
582
    {
583 67
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.additionalWhereClause';
584 67
        $additionalWhere = $this->getValueByPathOrDefaultValue($path, '');
585
586 67
        if (trim($additionalWhere) === '') {
0 ignored issues
show
Bug introduced by
It seems like $additionalWhere can also be of type array and null; 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

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

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

1221
            return mb_strtolower(/** @scrutinizer ignore-type */ $specificSortOrder);
Loading history...
1222
        }
1223
1224
        // no specific setting, check common setting
1225 3
        $commonPath = 'plugin.tx_solr.search.sorting.defaultOrder';
1226 3
        $commonATagParamOrDefaultValue = $this->getValueByPathOrDefaultValue($commonPath, $defaultIfEmpty);
1227 3
        return mb_strtolower($commonATagParamOrDefaultValue);
0 ignored issues
show
Bug introduced by
It seems like $commonATagParamOrDefaultValue can also be of type array and null; however, parameter $string of mb_strtolower() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

1227
        return mb_strtolower(/** @scrutinizer ignore-type */ $commonATagParamOrDefaultValue);
Loading history...
1228
    }
1229
1230
    /**
1231
     * Returns the trusted fields configured for the search that do not need to be escaped.
1232
     *
1233
     * @param array $defaultIfEmpty
1234
     * @return array
1235
     */
1236 9
    public function getSearchTrustedFieldsArray(array $defaultIfEmpty = ['url']): array
1237
    {
1238 9
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.trustedFields', '');
1239
1240 9
        if (trim($result) === '') {
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array and null; 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

1240
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
1241 3
            return $defaultIfEmpty;
1242
        }
1243
1244 6
        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

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

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

1567
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
1568
            return $defaultIfEmpty;
1569
        }
1570
1571
        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

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

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

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

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