getSearchFrequentSearchesConfiguration()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

566
        if (trim(/** @scrutinizer ignore-type */ $recursiveUpdateFieldsString) === '') {
Loading history...
567
            return $defaultIfEmpty;
568 26
        }
569 26
        $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

569
        $recursiveUpdateFields = GeneralUtility::trimExplode(',', /** @scrutinizer ignore-type */ $recursiveUpdateFieldsString);
Loading history...
570 26
        // For easier check later on we return an array by combining $recursiveUpdateFields
571 20
        return array_combine($recursiveUpdateFields, $recursiveUpdateFields);
0 ignored issues
show
Bug Best Practice introduced by
The expression return array_combine($re...$recursiveUpdateFields) could also return false which is incompatible with the documented return type array. Did you maybe forget to handle an error condition?

If the returned type also contains false, it is an indicator that maybe an error condition leading to the specific return statement remains unhandled.

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

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

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

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

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

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

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

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

1249
            return mb_strtolower(/** @scrutinizer ignore-type */ $specificSortOrder);
Loading history...
1250
        }
1251
1252
        // no specific setting, check common setting
1253
        $commonPath = 'plugin.tx_solr.search.sorting.defaultOrder';
1254
        $commonATagParamOrDefaultValue = $this->getValueByPathOrDefaultValue($commonPath, $defaultIfEmpty);
1255
        return mb_strtolower($commonATagParamOrDefaultValue);
1256
    }
1257
1258
    /**
1259 30
     * Returns the trusted fields configured for the search that do not need to be escaped.
1260
     *
1261 30
     * @param array $defaultIfEmpty
1262 30
     * @return array
1263
     */
1264
    public function getSearchTrustedFieldsArray($defaultIfEmpty = ['url'])
1265
    {
1266
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.trustedFields', '');
1267
1268
        if (trim($result) === '') {
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type array; however, parameter $str of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

1268
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
1269
            return $defaultIfEmpty;
1270
        }
1271
1272
        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

1272
        return GeneralUtility::trimExplode(',', /** @scrutinizer ignore-type */ $result);
Loading history...
1273 33
    }
1274
1275 33
    /**
1276 33
     * Indicates if the plugin arguments should be kept in the search form for a second submission.
1277
     *
1278
     * plugin.tx_solr.search.keepExistingParametersForNewSearches
1279
     *
1280
     * @param bool $defaultIfEmpty
1281
     * @return bool
1282
     */
1283
    public function getSearchKeepExistingParametersForNewSearches($defaultIfEmpty = false)
1284
    {
1285
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.keepExistingParametersForNewSearches', $defaultIfEmpty);
1286
        return $this->getBool($result);
1287 33
    }
1288
1289 33
    /**
1290 33
     * Returns if an empty query is allowed on the query level.
1291
     *
1292
     * plugin.tx_solr.search.query.allowEmptyQuery
1293
     *
1294
     * @param string $defaultIfEmpty
1295
     * @return bool
1296
     */
1297
    public function getSearchQueryAllowEmptyQuery($defaultIfEmpty = '')
1298
    {
1299
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.allowEmptyQuery', $defaultIfEmpty);
1300
        return $this->getBool($result);
1301 7
    }
1302
1303 7
    /**
1304 7
     * Returns the filter configuration array
1305
     *
1306
     * plugin.tx_solr.search.query.filter.
1307
     *
1308
     * @param array $defaultIfEmpty
1309
     * @return array
1310
     */
1311
    public function getSearchQueryFilterConfiguration(array $defaultIfEmpty = [])
1312
    {
1313
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.query.filter.', $defaultIfEmpty);
1314
        return $result;
1315 5
    }
1316
1317 5
    /**
1318 5
     * Can be used to overwrite the filterConfiguration.
1319
     *
1320
     * plugin.tx_solr.search.query.filter.
1321
     *
1322
     * @param array $configuration
1323
     */
1324
    public function setSearchQueryFilterConfiguration(array $configuration)
1325
    {
1326
        $this->configurationAccess->set('plugin.tx_solr.search.query.filter.', $configuration);
1327
    }
1328
1329 65
    /**
1330
     * Removes the pageSections filter setting.
1331 65
     *
1332 65
     * @return void
1333
     */
1334
    public function removeSearchQueryFilterForPageSections()
1335
    {
1336
        $this->configurationAccess->reset('plugin.tx_solr.search.query.filter.__pageSections');
1337
    }
1338
1339
    /**
1340
     * Returns the configured queryFields from TypoScript
1341
     *
1342
     * plugin.tx_solr.search.query.queryFields
1343 33
     *
1344
     * @param string $defaultIfEmpty
1345 33
     * @return string
1346 33
     */
1347
    public function getSearchQueryQueryFields($defaultIfEmpty = '')
1348
    {
1349
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.queryFields', $defaultIfEmpty);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...elds', $defaultIfEmpty) also could return the type array which is incompatible with the documented return type string.
Loading history...
1350
    }
1351
1352
    /**
1353
     * This method is used to check if a phrase search is enabled or not
1354
     *
1355
     * plugin.tx_solr.search.query.phrase = 1
1356
     *
1357
     * @param bool $defaultIfEmpty
1358
     * @return bool
1359
     */
1360
    public function getPhraseSearchIsEnabled(bool $defaultIfEmpty = false)
1361
    {
1362
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.phrase', $defaultIfEmpty);
1363 36
        return $this->getBool($result);
1364
    }
1365 36
1366 36
    /**
1367
     * Returns the configured phrase fields from TypoScript
1368
     *
1369 36
     * plugin.tx_solr.search.query.phrase.fields
1370 2
     *
1371
     * @param string $defaultIfEmpty
1372
     * @return string
1373
     */
1374 34
    public function getSearchQueryPhraseFields(string $defaultIfEmpty = '')
1375 34
    {
1376 34
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.phrase.fields', $defaultIfEmpty);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...elds', $defaultIfEmpty) also could return the type array which is incompatible with the documented return type string.
Loading history...
1377
    }
1378
1379
    /**
1380
     * This method is used to check if a bigram phrase search is enabled or not
1381
     *
1382
     * plugin.tx_solr.search.query.bigramPhrase = 1
1383
     *
1384
     * @param bool $defaultIfEmpty
1385
     * @return bool
1386
     */
1387
    public function getBigramPhraseSearchIsEnabled(bool $defaultIfEmpty = false)
1388
    {
1389
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.bigramPhrase', $defaultIfEmpty);
1390
        return $this->getBool($result);
1391
    }
1392
1393
    /**
1394
     * Returns the configured phrase fields from TypoScript
1395
     *
1396
     * plugin.tx_solr.search.query.bigramPhrase.fields
1397
     *
1398
     * @param string $defaultIfEmpty
1399
     * @return string
1400 40
     */
1401
    public function getSearchQueryBigramPhraseFields(string $defaultIfEmpty = '')
1402 40
    {
1403
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.bigramPhrase.fields', $defaultIfEmpty);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...elds', $defaultIfEmpty) also could return the type array which is incompatible with the documented return type string.
Loading history...
1404 40
    }
1405 3
1406
    /**
1407
     * This method is used to check if a trigram phrase search is enabled or not
1408 37
     *
1409
     * plugin.tx_solr.search.query.trigramPhrase = 1
1410
     *
1411
     * @param bool $defaultIfEmpty
1412
     * @return bool
1413
     */
1414
    public function getTrigramPhraseSearchIsEnabled(bool $defaultIfEmpty = false)
1415
    {
1416
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.trigramPhrase', $defaultIfEmpty);
1417
        return $this->getBool($result);
1418
    }
1419
1420
    /**
1421
     * Returns the configured trigram phrase fields from TypoScript
1422
     *
1423
     * plugin.tx_solr.search.query.trigramPhrase.fields
1424
     *
1425
     * @param string $defaultIfEmpty
1426
     * @return string
1427
     */
1428
    public function getSearchQueryTrigramPhraseFields(string $defaultIfEmpty = '')
1429
    {
1430
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.trigramPhrase.fields', $defaultIfEmpty);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...elds', $defaultIfEmpty) also could return the type array which is incompatible with the documented return type string.
Loading history...
1431
    }
1432
1433 120
    /**
1434
     * Returns the configured returnFields as array.
1435 120
     *
1436 120
     * plugin.tx_solr.search.query.returnFields
1437
     *
1438
     * @param array $defaultIfEmpty
1439
     * @return array
1440
     */
1441
    public function getSearchQueryReturnFieldsAsArray($defaultIfEmpty = [])
1442
    {
1443
        $returnFields = $this->getValueByPath('plugin.tx_solr.search.query.returnFields');
1444
        if (is_null($returnFields)) {
1445
            return $defaultIfEmpty;
1446
        }
1447 133
1448
        return GeneralUtility::trimExplode(',', $returnFields);
0 ignored issues
show
Bug introduced by
$returnFields of type array is incompatible with the type string expected by parameter $string of TYPO3\CMS\Core\Utility\G...lUtility::trimExplode(). ( Ignorable by Annotation )

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

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

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

1597
        if (trim(/** @scrutinizer ignore-type */ $result) === '') {
Loading history...
1598 36
            return $defaultIfEmpty;
1599
        }
1600 36
1601
        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

1601
        return GeneralUtility::intExplode(',', /** @scrutinizer ignore-type */ $result, true);
Loading history...
1602
    }
1603 36
1604
    /**
1605
     * Returns the configured wrap for the resultHighlighting.
1606
     *
1607
     * plugin.tx_solr.search.results.resultsHighlighting.wrap
1608
     *
1609
     * @param string $defaultIfEmpty
1610
     * @return string
1611
     */
1612
    public function getSearchResultsHighlightingWrap($defaultIfEmpty = '')
1613
    {
1614
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsHighlighting.wrap', $defaultIfEmpty);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueBy...wrap', $defaultIfEmpty) also could return the type array which is incompatible with the documented return type string.
Loading history...
1615
    }
1616
1617
    /**
1618
     * Indicates if spellchecking is enabled or not.
1619
     *
1620
     * plugin.tx_solr.search.spellchecking
1621
     *
1622
     * @param bool $defaultIfEmpty
1623
     * @return bool
1624
     */
1625
    public function getSearchSpellchecking($defaultIfEmpty = false)
1626
    {
1627
        $isFacetingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking', $defaultIfEmpty);
1628
        return $this->getBool($isFacetingEnabled);
1629 26
    }
1630
1631 26
    /**
1632 26
     * Returns the numberOfSuggestionsToTry that should be used for the spellchecking.
1633
     *
1634
     * plugin.tx_solr.search.spellchecking.numberOfSuggestionsToTry
1635
     *
1636
     * @param int $defaultIfEmpty
1637
     * @return int
1638
     */
1639
    public function getSearchSpellcheckingNumberOfSuggestionsToTry($defaultIfEmpty = 1)
1640
    {
1641
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking.numberOfSuggestionsToTry', $defaultIfEmpty);
1642
    }
1643
1644 123
    /**
1645
     * Indicates if a second search should be fired from the spellchecking suggestion if no results could be found.
1646 123
     *
1647 123
     * plugin.tx_solr.search.spellchecking.searchUsingSpellCheckerSuggestion
1648
     *
1649
     * @param bool $defaultIfEmpty
1650
     * @return bool
1651
     */
1652
    public function getSearchSpellcheckingSearchUsingSpellCheckerSuggestion($defaultIfEmpty = false)
1653
    {
1654
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking.searchUsingSpellCheckerSuggestion', $defaultIfEmpty);
1655
        return $this->getBool($result);
1656
    }
1657
1658 40
    /**
1659
     * Indicates if faceting is enabled or not.
1660 40
     *
1661
     * plugin.tx_solr.search.faceting
1662
     *
1663
     * @param bool $defaultIfEmpty
1664
     * @return bool
1665
     */
1666
    public function getSearchFaceting($defaultIfEmpty = false)
1667
    {
1668
        $isFacetingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting', $defaultIfEmpty);
1669
        return $this->getBool($isFacetingEnabled);
1670
    }
1671
1672
    /**
1673
     * Retrieves the showEvenWhenEmpty for a facet by facet name. If nothing specific is configured
1674
     * the global showEmptyFacets with be returned.
1675
     *
1676
     * plugin.tx_solr.search.faceting.facets.<facetName>.showEvenWhenEmpty
1677
     *
1678
     * or
1679
     *
1680
     * plugin.tx_solr.search.faceting.showEmptyFacets
1681
     *
1682
     *
1683
     * @param string $facetName
1684
     * @param bool $defaultIfEmpty
1685
     * @return bool
1686
     */
1687
    public function getSearchFacetingShowEmptyFacetsByName($facetName = '', $defaultIfEmpty = false)
1688
    {
1689
        $facetSpecificPath = 'plugin.tx_solr.search.faceting.facets.' . $facetName . '.showEvenWhenEmpty';
1690 40
        $specificShowWhenEmpty = $this->getValueByPathOrDefaultValue($facetSpecificPath, null);
1691
1692 40
        // if we have a concrete setting, use it
1693
        if ($specificShowWhenEmpty !== null) {
1694
            return $specificShowWhenEmpty;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $specificShowWhenEmpty returns the type array which is incompatible with the documented return type boolean.
Loading history...
1695
        }
1696
1697
        // no specific setting, check common setting
1698
        $commonPath = 'plugin.tx_solr.search.faceting.showEmptyFacets';
1699
        $commonIfEmptyOrDefaultValue = $this->getValueByPathOrDefaultValue($commonPath, $defaultIfEmpty);
1700
        return $commonIfEmptyOrDefaultValue;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $commonIfEmptyOrDefaultValue also could return the type array which is incompatible with the documented return type boolean.
Loading history...
1701
    }
1702
1703 26
    /**
1704
     * Returns the wrap for the faceting show all link
1705 26
     *
1706
     * plugin.tx_solr.search.faceting.showAllLink.wrap
1707
     *
1708
     * @param string $defaultIfEmpty
1709
     * @return string
1710
     */
1711
    public function getSearchFacetingShowAllLinkWrap($defaultIfEmpty = '')
1712
    {
1713
        return (string)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.showAllLink.wrap', $defaultIfEmpty);
1714
    }
1715
1716 35
    /**
1717
     * Returns the link url parameters that should be added to a facet.
1718 35
     *
1719
     * plugin.tx_solr.search.faceting.facetLinkUrlParameters
1720
     *
1721
     * @param string $defaultIfEmpty
1722
     * @return string
1723
     */
1724
    public function getSearchFacetingFacetLinkUrlParameters($defaultIfEmpty = '')
1725
    {
1726
        $linkUrlParameters = trim($this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.facetLinkUrlParameters', $defaultIfEmpty));
0 ignored issues
show
Bug introduced by
It seems like $this->getValueByPathOrD...ters', $defaultIfEmpty) can also be of type array; however, parameter $str of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

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

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

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