Completed
Push — master ( c7f02f...d53d83 )
by Timo
14:49
created

getLoggingIndexingQueueOperationsByConfigurationNameWithFallBack()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.0175

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 7
cts 8
cp 0.875
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 2
crap 3.0175
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 2 of the License, or
14
 *  (at your option) any later version.
15
 *
16
 *  The GNU General Public License can be found at
17
 *  http://www.gnu.org/copyleft/gpl.html.
18
 *  A copy is found in the textfile GPL.txt and important notices to the license
19
 *  from the author is found in LICENSE.txt distributed with these scripts.
20
 *
21
 *
22
 *  This script is distributed in the hope that it will be useful,
23
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 *  GNU General Public License for more details.
26
 *
27
 *  This copyright notice MUST APPEAR in all copies of the script!
28
 ***************************************************************/
29
30
use ApacheSolrForTypo3\Solr\IndexQueue\Indexer;
31
use ApacheSolrForTypo3\Solr\IndexQueue\Initializer\Record;
32
use ApacheSolrForTypo3\Solr\System\ContentObject\ContentObjectService;
33
use ApacheSolrForTypo3\Solr\System\Util\ArrayAccessor;
34
use InvalidArgumentException;
35
use TYPO3\CMS\Core\Utility\ArrayUtility;
36
use TYPO3\CMS\Core\Utility\GeneralUtility;
37
38
/**
39
 * TypoScript configuration object, used to read all TypoScript configuration.
40
 *
41
 * The TypoScriptConfiguration was introduced in order to be able to replace the old,
42
 * array based configuration with one configuration object.
43
 *
44
 * To read the configuration, you should use
45
 *
46
 * $configuration->getValueByPath
47
 *
48
 * or
49
 *
50
 * $configuration->isValidPath
51
 *
52
 * to check if an configuration path exists.
53
 *
54
 * To ensure Backwards compatibility the TypoScriptConfiguration object implements the
55
 * ArrayAccess interface (offsetGet,offsetExists,offsetUnset and offsetSet)
56
 *
57
 * This was only introduced to be backwards compatible in logTerm only "getValueByPath", "isValidPath" or
58
 * speaking methods for configuration settings should be used!
59
 *
60
 * @author Marc Bastian Heinrichs <[email protected]>
61
 * @author Timo Schmidt <[email protected]>
62
 */
63
class TypoScriptConfiguration
64
{
65
    /**
66
     * @var \ApacheSolrForTypo3\Solr\System\Util\ArrayAccessor|null
67
     */
68
    protected $configurationAccess = null;
69
70
    /**
71
     * Holds the pageId in which context the configuration was parsed
72
     * (normally $GLOBALS['TSFE']->id)
73
     */
74
    protected $contextPageId = 0;
75
76
    /**
77
     * @var ContentObjectService
78
     */
79
    protected $contentObjectService;
80
81
    /**
82
     * @param array $configuration
83
     * @param int $contextPageId
84
     * @param ContentObjectService $contentObjectService
85
     */
86 216
    public function __construct(array $configuration, $contextPageId = 0, ContentObjectService $contentObjectService = null)
87
    {
88 216
        $this->configurationAccess = new ArrayAccessor($configuration, '.', true);
89 216
        $this->contextPageId = $contextPageId;
90 216
        $this->contentObjectService = is_null($contentObjectService) ? GeneralUtility::makeInstance(ContentObjectService::class) : $contentObjectService;
91 216
    }
92
93
    /**
94
     * Checks if a value is 1, '1', 'true'
95
     * @param mixed $value
96
     * @return bool
97
     */
98 199
    protected function getBool($value)
99
    {
100 199
        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 7
    protected function getOnlyArrayKeysWhereValueIsNotAnArray($inputArray)
113
    {
114 7
        $keysWithNonArrayValue = [];
115
116 7
        foreach ($inputArray as $key => $value) {
117 7
            if (is_array($value)) {
118
                // configuration for a content object, skipping
119 6
                continue;
120
            }
121
122 7
            $keysWithNonArrayValue[] = $key;
123
        }
124
125 7
        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 array The TypoScript object defined by the given path
141
     * @throws InvalidArgumentException
142
     */
143 237
    public function getValueByPath($path)
144
    {
145 237
        if (!is_string($path)) {
146
            throw new InvalidArgumentException('Parameter $path is not a string',
147
                1325623321);
148
        }
149
150 237
        return $this->configurationAccess->get($path);
151
    }
152
153
    /**
154
     * This method can be used to get  a configuration value by path if it exists or return a
155
     * default value when it does not exist.
156
     *
157
     * @param string $path
158
     * @param mixed $defaultValue
159
     * @return mixed
160
     */
161 236
    public function getValueByPathOrDefaultValue($path, $defaultValue)
162
    {
163 236
        $value = $this->getValueByPath($path);
164 236
        if (is_null($value)) {
165 219
            return $defaultValue;
166
        }
167
168 163
        return $value;
169
    }
170
171
    /**
172
     * Gets the parent TypoScript Object from a given TypoScript path.
173
     *
174
     * In the context of an frontend content element the path plugin.tx_solr is
175
     * merged recursive with overrule with the content element specific typoscript
176
     * settings, like plugin.tx_solr_PiResults_Results, and possible flex form settings
177
     * (depends on the solr plugin).
178
     *
179
     * Example: plugin.tx_solr.index.queue.tt_news.fields.content
180
     * returns $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['index.']['queue.']['tt_news.']['fields.']['content.']
181
     * which is a SOLR_CONTENT cObj.
182
     *
183
     * @param string $path TypoScript path
184
     * @return array The TypoScript object defined by the given path
185
     * @throws InvalidArgumentException
186
     */
187 125
    public function getObjectByPath($path)
188
    {
189 125
        if (substr($path, -1) !== '.') {
190 4
            $path = rtrim($path, '.');
191 4
            $path = substr($path, 0, strrpos($path, '.') + 1);
192
        }
193
194 125
        if (!is_string($path)) {
195
            throw new InvalidArgumentException('Parameter $path is not a string', 1325627243);
196
        }
197
198 125
        return $this->configurationAccess->get($path);
199
    }
200
201
    /**
202
     * Gets the parent TypoScript Object from a given TypoScript path and if not present return
203
     * the default value
204
     *
205
     * @see getObjectByPath
206
     * @param string $path
207
     * @param array $defaultValue
208
     * @return array
209
     */
210 117
    public function getObjectByPathOrDefault($path, array $defaultValue)
211
    {
212
        try {
213 117
            $object = $this->getObjectByPath($path);
214
        } catch (\InvalidArgumentException $e) {
215
            return $defaultValue;
216
        }
217
218 117
        if (!is_array($object)) {
219 45
            return $defaultValue;
220
        }
221
222 105
        return $object;
223
    }
224
225
    /**
226
     * Checks whether a given TypoScript path is valid.
227
     *
228
     * @param string $path TypoScript path
229
     * @return bool TRUE if the path resolves, FALSE otherwise
230
     */
231
    public function isValidPath($path)
232
    {
233
        $isValidPath = false;
234
235
        $pathValue = $this->getValueByPath($path);
236
        if (!is_null($pathValue)) {
237
            $isValidPath = true;
238
        }
239
240
        return $isValidPath;
241
    }
242
243
    /**
244
     * Merges a configuration with another configuration a
245
     *
246
     * @param array $configurationToMerge
247
     * @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.
248
     * @param bool $includeEmptyValues If set, values from $overrule will overrule if they are empty or zero.
249
     * @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.
250
     * @return TypoScriptConfiguration
251
     */
252 27
    public function mergeSolrConfiguration(array $configurationToMerge, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true)
253
    {
254 27
        $data = $this->configurationAccess->getData();
255 27
        ArrayUtility::mergeRecursiveWithOverrule(
256 27
            $data['plugin.']['tx_solr.'],
257
            $configurationToMerge,
258
            $addKeys,
259
            $includeEmptyValues,
260
            $enableUnsetFeature
261
        );
262
263 27
        $this->configurationAccess->setData($data);
264
265 27
        return $this;
266
    }
267
268
    /**
269
     * Returns true when ext_solr is enabled
270
     *
271
     * @param boolean $defaultIfEmpty
272
     * @return boolean
273
     */
274 3
    public function getEnabled($defaultIfEmpty = false)
275
    {
276 3
        $path = 'plugin.tx_solr.enabled';
277 3
        $result = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty);
278 3
        return $this->getBool($result);
279
    }
280
281
    /**
282
     * Returns the configured css file for a specific fileKey.
283
     *
284
     * plugin.tx_solr.cssFiles.<fileKey>
285
     *
286
     * @param string $fileKey
287
     * @param string $defaultIfEmpty
288
     * @return string
289
     */
290 25
    public function getCssFileByFileKey($fileKey, $defaultIfEmpty = '')
291
    {
292 25
        $cssFileName = $this->getValueByPathOrDefaultValue('plugin.tx_solr.cssFiles.' . $fileKey, $defaultIfEmpty);
293 25
        return (string)$cssFileName;
294
    }
295
296
    /**
297
     * Returns the configured additionalFields configured for the indexing.
298
     *
299
     * plugin.tx_solr.index.additionalFields.
300
     *
301
     * @param array $defaultIfEmpty
302
     * @return array
303
     */
304 3
    public function getIndexAdditionalFieldsConfiguration($defaultIfEmpty = [])
305
    {
306 3
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.index.additionalFields.', $defaultIfEmpty);
307 3
        return $result;
308
    }
309
310
    /**
311
     * Returns all solr fields names where a mapping is configured in index.additionalFields
312
     *
313
     * Returns all keys from
314
     * plugin.tx_solr.index.additionalFields.
315
     *
316
     * @param array $defaultIfEmpty
317
     * @return array
318
     */
319 2
    public function getIndexMappedAdditionalFieldNames($defaultIfEmpty = [])
320
    {
321 2
        $mappingConfiguration = $this->getIndexAdditionalFieldsConfiguration();
322 2
        $mappedFieldNames = $this->getOnlyArrayKeysWhereValueIsNotAnArray($mappingConfiguration);
323 2
        return count($mappedFieldNames) == 0 ? $defaultIfEmpty : $mappedFieldNames;
324
    }
325
326
    /**
327
     * Returns the fieldProcessingInstructions configuration array
328
     *
329
     * plugin.tx_solr.index.fieldProcessingInstructions.
330
     *
331
     * @param array $defaultIfEmpty
332
     * @return array
333
     */
334 51
    public function getIndexFieldProcessingInstructionsConfiguration(array $defaultIfEmpty = [])
335
    {
336 51
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.index.fieldProcessingInstructions.', $defaultIfEmpty);
337 51
        return $result;
338
    }
339
340
    /**
341
     * Retrieves the indexing configuration array for an indexing queue by configuration name.
342
     *
343
     * plugin.tx_solr.index.queue.<configurationName>.
344
     *
345
     * @param string $configurationName
346
     * @param array $defaultIfEmpty
347
     * @return array
348
     */
349 5
    public function getIndexQueueConfigurationByName($configurationName, array $defaultIfEmpty = [])
350
    {
351 5
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.';
352 5
        $result = $this->getObjectByPathOrDefault($path, $defaultIfEmpty);
353 5
        return $result;
354
    }
355
356
    /**
357
     * Returns an array of all allowedPageTypes.
358
     *
359
     * plugin.tx_solr.index.queue.pages.allowedPageTypes
360
     *
361
     * @param string $configurationName The configuration name of the queue to use.
362
     * @param array $defaultIfEmpty
363
     * @return array
364
     */
365 28
    public function getIndexQueueAllowedPageTypesArrayByConfigurationName($configurationName = 'pages', $defaultIfEmpty = [])
366
    {
367 28
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.allowedPageTypes';
368 28
        $result = $this->getValueByPathOrDefaultValue($path, '');
369 28
        if (trim($result) == '') {
370
            return $defaultIfEmpty;
371
        }
372
373 28
        return GeneralUtility::trimExplode(',', $result);
374
    }
375
376
    /**
377
     * Returns an array of all allowedPageTypes.
378
     *
379
     * plugin.tx_solr.index.queue.pages.allowedPageTypes
380
     *
381
     * @deprecated since 6.0 will be removed in 7.0
382
     *
383
     * @param array $defaultIfEmpty
384
     * @return array
385
     */
386 1
    public function getIndexQueuePagesAllowedPageTypesArray($defaultIfEmpty = [])
387
    {
388 1
        return $this->getIndexQueueAllowedPageTypesArrayByConfigurationName(
389 1
            'pages',
390
            $defaultIfEmpty
391
        );
392
    }
393
394
    /**
395
     * Returns the configured excludeContentByClass patterns as array.
396
     *
397
     * plugin.tx_solr.index.queue.pages.excludeContentByClass
398
     *
399
     * @param array $defaultIfEmpty
400
     * @return array
401
     */
402 36
    public function getIndexQueuePagesExcludeContentByClassArray($defaultIfEmpty = [])
403
    {
404 36
        $path = 'plugin.tx_solr.index.queue.pages.excludeContentByClass';
405 36
        $result = $this->getValueByPathOrDefaultValue($path, '');
406
407 36
        if (trim($result) == '') {
408 6
            return $defaultIfEmpty;
409
        }
410
411 30
        return GeneralUtility::trimExplode(',', $result);
412
    }
413
414
    /**
415
     * Returns the configured database table for an indexing queue configuration or
416
     * the configurationName itself that is used by convention as tableName when no
417
     * other tablename is present.
418
     *
419
     * plugin.tx_solr.index.queue.<configurationName>.table or configurationName
420
     *
421
     * @param string $configurationName
422
     * @return string
423
     */
424 38
    public function getIndexQueueTableNameOrFallbackToConfigurationName($configurationName = '')
425
    {
426 38
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.table';
427 38
        $result = $this->getValueByPathOrDefaultValue($path, $configurationName);
428 38
        return $result;
429
    }
430
431
    /**
432
     * Returns the field configuration for a specific index queue.
433
     *
434
     * plugin.tx_solr.index.queue.<configurationName>.fields.
435
     *
436
     * @param string $configurationName
437
     * @param array $defaultIfEmpty
438
     * @return array
439
     */
440 17
    public function getIndexQueueFieldsConfigurationByConfigurationName($configurationName = '', $defaultIfEmpty = [])
441
    {
442 17
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.fields.';
443 17
        $result = $this->getObjectByPathOrDefault($path, $defaultIfEmpty);
444 17
        return $result;
445
    }
446
447
    /**
448
     * Gets an array of tables configured for indexing by the Index Queue. Since the
449
     * record monitor must watch these tables for manipulation.
450
     *
451
     * @return array Array of table names to be watched by the record monitor.
452
     */
453 29
    public function getIndexQueueMonitoredTables()
454
    {
455 29
        $monitoredTables = [];
456
457 29
        $indexingConfigurations = $this->getEnabledIndexQueueConfigurationNames();
458 29
        foreach ($indexingConfigurations as $indexingConfigurationName) {
459 29
            $monitoredTable = $this->getIndexQueueTableNameOrFallbackToConfigurationName($indexingConfigurationName);
460 29
            $monitoredTables[] = $monitoredTable;
461 29
            if ($monitoredTable == 'pages') {
462
                // when monitoring pages, also monitor creation of translations
463 29
                $monitoredTables[] = 'pages_language_overlay';
464
            }
465
        }
466
467 29
        return array_values(array_unique($monitoredTables));
468
    }
469
470
    /**
471
     * This method can be used to check if a table is configured to be monitored by the record monitor.
472
     *
473
     * @param string $tableName
474
     * @return bool
475
     */
476 28
    public function getIndexQueueIsMonitoredTable($tableName)
477
    {
478 28
        return in_array($tableName, $this->getIndexQueueMonitoredTables(), true);
479
    }
480
481
    /**
482
     * Returns the configured indexer class that should be used for a certain indexingConfiguration.
483
     * By default "ApacheSolrForTypo3\Solr\IndexQueue\Indexer" will be returned.
484
     *
485
     * plugin.tx_solr.index.queue.<configurationName>.indexer
486
     *
487
     * @param string $configurationName
488
     * @param string $defaultIfEmpty
489
     * @return string
490
     */
491 6
    public function getIndexQueueIndexerByConfigurationName($configurationName, $defaultIfEmpty = Indexer::class)
492
    {
493 6
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.indexer';
494 6
        $result = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty);
495 6
        return $result;
496
    }
497
498
    /**
499
     * Returns the configuration of an indexer for a special indexingConfiguration. By default an empty
500
     * array is returned.
501
     *
502
     * plugin.tx_solr.index.queue.<configurationName>.indexer.
503
     *
504
     * @param string $configurationName
505
     * @param array $defaultIfEmpty
506
     * @return array
507
     */
508 6
    public function getIndexQueueIndexerConfigurationByConfigurationName($configurationName, $defaultIfEmpty = [])
509
    {
510 6
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.indexer.';
511 6
        $result = $this->getObjectByPathOrDefault($path, $defaultIfEmpty);
512 6
        return $result;
513
    }
514
515
    /**
516
     * Returns all solr fields names where a mapping configuration is set for a certain index configuration
517
     *
518
     * Returns all keys from
519
     * plugin.tx_solr.index.queue.<configurationName>.fields.
520
     *
521
     * @param string $configurationName
522
     * @param array $defaultIfEmpty
523
     * @return array
524
     */
525 6
    public function getIndexQueueMappedFieldsByConfigurationName($configurationName = '', $defaultIfEmpty = [])
526
    {
527 6
        $mappingConfiguration = $this->getIndexQueueFieldsConfigurationByConfigurationName($configurationName);
528 6
        $mappedFieldNames = $this->getOnlyArrayKeysWhereValueIsNotAnArray($mappingConfiguration);
529 6
        return count($mappedFieldNames) == 0 ? $defaultIfEmpty : $mappedFieldNames;
530
    }
531
532
    /**
533
     * This method is used to check if an index queue configuration is enabled or not
534
     *
535
     * plugin.tx_solr.index.queue.<configurationName> = 1
536
     *
537
     * @param string $configurationName
538
     * @param bool $defaultIfEmpty
539
     * @return bool
540
     */
541 31
    public function getIndexQueueConfigurationIsEnabled($configurationName, $defaultIfEmpty = false)
542
    {
543 31
        $path = 'plugin.tx_solr.index.queue.' . $configurationName;
544 31
        $result = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty);
545 31
        return $this->getBool($result);
546
    }
547
548
    /**
549
     * Retrieves an array of enabled index queue configurations.
550
     *
551
     * plugin.tx_solr.index.queue.<configurationName>
552
     *
553
     * @param array $defaultIfEmpty
554
     * @return array
555
     */
556 39
    public function getEnabledIndexQueueConfigurationNames($defaultIfEmpty = [])
557
    {
558 39
        $tablesToIndex = [];
559 39
        $path = 'plugin.tx_solr.index.queue.';
560 39
        $indexQueueConfiguration = $this->getObjectByPathOrDefault($path, []);
561 39
        foreach ($indexQueueConfiguration as $configurationName => $indexingEnabled) {
562 38
            if (substr($configurationName, -1) != '.' && $indexingEnabled) {
563 38
                $tablesToIndex[] = $configurationName;
564
            }
565
        }
566
567 39
        return count($tablesToIndex) == 0 ? $defaultIfEmpty : $tablesToIndex;
568
    }
569
570
    /**
571
     * Retrieves an array of additional fields that will trigger an recursive update of pages
572
     * when some of the fields on that page are modified.
573
     *
574
     * plugin.tx_solr.index.queue.recursiveUpdateFields
575
     *
576
     * @param string $configurationName
577
     * @param array $defaultIfEmpty
578
     * @return array
579
     */
580 23
    public function getIndexQueueConfigurationRecursiveUpdateFields($configurationName, $defaultIfEmpty = [])
581
    {
582 23
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.recursiveUpdateFields';
583 23
        $recursiveUpdateFieldsString = $this->getValueByPathOrDefaultValue($path, '');
584 23
        if (trim($recursiveUpdateFieldsString) === '') {
585 17
            return $defaultIfEmpty;
586
        }
587 7
        $recursiveUpdateFields = GeneralUtility::trimExplode(',', $recursiveUpdateFieldsString);
588
        // For easier check later on we return an array by combining $recursiveUpdateFields
589 7
        return array_combine($recursiveUpdateFields, $recursiveUpdateFields);
590
    }
591
592
593
    /**
594
     * Retrieves and initialPagesAdditionalWhereClause where clause when configured or an empty string.
595
     *
596
     * plugin.tx_solr.index.queue.<configurationName>.initialPagesAdditionalWhereClause
597
     *
598
     * @param string $configurationName
599
     * @return string
600
     */
601 9
    public function getInitialPagesAdditionalWhereClause($configurationName)
602
    {
603 9
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.initialPagesAdditionalWhereClause';
604 9
        $initialPagesAdditionalWhereClause = $this->getValueByPathOrDefaultValue($path, '');
605
606 9
        if (trim($initialPagesAdditionalWhereClause) === '') {
607 9
            return '';
608
        }
609
610 1
        return ' AND ' . $initialPagesAdditionalWhereClause;
611
    }
612
613
    /**
614
     * Retrieves and additional where clause when configured or an empty string.
615
     *
616
     * plugin.tx_solr.index.queue.<configurationName>.additionalWhereClause
617
     *
618
     * @param string $configurationName
619
     * @return string
620
     */
621 48
    public function getIndexQueueAdditionalWhereClauseByConfigurationName($configurationName)
622
    {
623 48
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.additionalWhereClause';
624 48
        $additionalWhere = $this->getValueByPathOrDefaultValue($path, '');
625
626 48
        if (trim($additionalWhere) === '') {
627 11
            return '';
628
        }
629
630 38
        return ' AND ' . $additionalWhere;
631
    }
632
633
    /**
634
     * This method can be used to retrieve all index queue configuration names, where
635
     * a certain table is used. It can be configured with the property "table" or is using the configuration
636
     * key a fallback for the table name.
637
     *
638
     * plugin.tx_solr.index.queue.<configurationName>.
639
     *
640
     * @param string $tableName
641
     * @param array $defaultIfEmpty
642
     * @return array
643
     */
644 10
    public function getIndexQueueConfigurationNamesByTableName($tableName, $defaultIfEmpty = [])
645
    {
646 10
        $path = 'plugin.tx_solr.index.queue.';
647 10
        $configuration = $this->getObjectByPathOrDefault($path, []);
648 10
        $possibleConfigurations = [];
649
650 10
        foreach ($configuration as $configurationName => $indexingEnabled) {
651 10
            $isObject = substr($configurationName, -1) == '.';
652 10
            if ($isObject || !$indexingEnabled) {
653 10
                continue;
654
            }
655
656
            // when the configuration name equals the tableName we have a fallback
657 10
            $hasTableNameAsConfigurationName = $configurationName == $tableName;
658 10
            $hasTableAssignedInQueueConfiguration = isset($configuration[$configurationName . '.']['table']) &&
659 10
                                                    $configuration[$configurationName . '.']['table'] == $tableName;
660 10
            if ($hasTableNameAsConfigurationName || $hasTableAssignedInQueueConfiguration) {
661 10
                $possibleConfigurations[] = $configurationName;
662
            }
663
        }
664
665 10
        return count($possibleConfigurations) > 0 ? $possibleConfigurations : $defaultIfEmpty;
666
    }
667
668
    /**
669
     * This method is used to retrieve the className of a queue initializer for a certain indexing configuration
670
     * of returns the default initializer class, when noting is configured.
671
     *
672
     * plugin.tx_solr.index.queue.<configurationName>.initialization
673
     *
674
     * @param string $configurationName
675
     * @param string $defaultIfEmpty
676
     * @return string
677
     */
678 5
    public function getIndexQueueInitializerClassByConfigurationName($configurationName, $defaultIfEmpty = Record::class)
679
    {
680 5
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.initialization';
681 5
        $className = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty);
682
683 5
        return $className;
684
    }
685
686
    /**
687
     * Returns the configured javascript file for a specific fileKey.
688
     *
689
     * plugin.tx_solr.javascriptFiles.<fileKey>
690
     *
691
     * @param string $fileKey
692
     * @param string $defaultIfEmpty
693
     * @return string
694
     */
695 26
    public function getJavaScriptFileByFileKey($fileKey, $defaultIfEmpty = '')
696
    {
697 26
        $javaScriptFileName = $this->getValueByPathOrDefaultValue('plugin.tx_solr.javascriptFiles.' . $fileKey, $defaultIfEmpty);
698 26
        return (string)$javaScriptFileName;
699
    }
700
701
    /**
702
     * Returns the configuration where to load the javascript
703
     *
704
     * plugin.tx_solr.javascriptFiles.loadIn
705
     *
706
     * @param string $defaultIfEmpty
707
     * @return string
708
     */
709 25
    public function getJavaScriptLoadIn($defaultIfEmpty = 'footer')
710
    {
711 25
        $loadIn = $this->getValueByPathOrDefaultValue('plugin.tx_solr.javascriptFiles.loadIn', $defaultIfEmpty);
712 25
        return (string)$loadIn;
713
    }
714
715
    /**
716
     * Returns the _LOCAL_LANG configuration from the TypoScript.
717
     *
718
     * plugin.tx_solr._LOCAL_LANG.
719
     *
720
     * @param array $defaultIfEmpty
721
     * @return array
722
     */
723 25
    public function getLocalLangConfiguration(array $defaultIfEmpty = [])
724
    {
725 25
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr._LOCAL_LANG.', $defaultIfEmpty);
726 25
        return $result;
727
    }
728
729
    /**
730
     * When this is enabled the output of the devlog, will be printed as debug output.
731
     *
732
     * @param bool $defaultIfEmpty
733
     * @return bool
734
     */
735
    public function getLoggingDebugOutputDevlog($defaultIfEmpty = false)
736
    {
737
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.debugDevlogOutput', $defaultIfEmpty);
738
        return $this->getBool($result);
739
    }
740
741
    /**
742
     * Returns if query filters should be written to the log.
743
     *
744
     * plugin.tx_solr.logging.query.filters
745
     *
746
     * @param bool $defaultIfEmpty
747
     * @return bool
748
     */
749 37
    public function getLoggingQueryFilters($defaultIfEmpty = false)
750
    {
751 37
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.filters', $defaultIfEmpty);
752 37
        return $this->getBool($result);
753
    }
754
755
    /**
756
     * Returns if the querystring should be logged or not.
757
     *
758
     * plugin.tx_solr.logging.query.queryString
759
     *
760
     * @param bool $defaultIfEmpty
761
     * @return bool
762
     */
763 25
    public function getLoggingQueryQueryString($defaultIfEmpty = false)
764
    {
765 25
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.queryString', $defaultIfEmpty);
766 25
        return $this->getBool($result);
767
    }
768
769
    /**
770
     * Returns if the searchWords should be logged or not.
771
     *
772
     * plugin.tx_solr.logging.query.searchWords
773
     *
774
     * @param bool $defaultIfEmpty
775
     * @return bool
776
     */
777 24
    public function getLoggingQuerySearchWords($defaultIfEmpty = false)
778
    {
779 24
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.searchWords', $defaultIfEmpty);
780 24
        return $this->getBool($result);
781
    }
782
783
    /**
784
     * Returns if the rawGet requests should be logged or not.
785
     *
786
     * plugin.tx_solr.logging.query.rawGet
787
     *
788
     * @param bool $defaultIfEmpty
789
     * @return bool
790
     */
791 35
    public function getLoggingQueryRawGet($defaultIfEmpty = false)
792
    {
793 35
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.rawGet', $defaultIfEmpty);
794 35
        return $this->getBool($result);
795
    }
796
797
    /**
798
     * Returns if the rawPost requests should be logged or not.
799
     *
800
     * plugin.tx_solr.logging.query.rawPost
801
     *
802
     * @param bool $defaultIfEmpty
803
     * @return bool
804
     */
805 57
    public function getLoggingQueryRawPost($defaultIfEmpty = false)
806
    {
807 57
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.rawPost', $defaultIfEmpty);
808 57
        return $this->getBool($result);
809
    }
810
811
    /**
812
     * Returns if the rawDelete requests should be logged or not.
813
     *
814
     * plugin.tx_solr.logging.query.rawDelete
815
     *
816
     * @param bool $defaultIfEmpty
817
     * @return bool
818
     */
819 2
    public function getLoggingQueryRawDelete($defaultIfEmpty = false)
820
    {
821 2
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.rawDelete', $defaultIfEmpty);
822 2
        return $this->getBool($result);
823
    }
824
825
    /**
826
     * Returns if exceptions should be logged or not.
827
     *
828
     * plugin.tx_solr.logging.exceptions
829
     *
830
     * @param bool $defaultIfEmpty
831
     * @return bool
832
     */
833 1
    public function getLoggingExceptions($defaultIfEmpty = true)
834
    {
835 1
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.exceptions', $defaultIfEmpty);
836 1
        return $this->getBool($result);
837
    }
838
839
    /**
840
     * Returns if indexing operations should be logged or not.
841
     *
842
     * plugin.tx_solr.logging.indexing
843
     *
844
     * @param bool $defaultIfEmpty
845
     * @return bool
846
     */
847 54
    public function getLoggingIndexing($defaultIfEmpty = false)
848
    {
849 54
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing', $defaultIfEmpty);
850 54
        return $this->getBool($result);
851
    }
852
853
    /**
854
     * Returns if indexing queue operations should be logged or not.
855
     *
856
     * plugin.tx_solr.logging.indexing.queue
857
     *
858
     * @param bool $defaultIfEmpty
859
     * @return bool
860
     */
861 12
    public function getLoggingIndexingQueue($defaultIfEmpty = false)
862
    {
863 12
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing.queue', $defaultIfEmpty);
864 12
        return $this->getBool($result);
865
    }
866
867
    /**
868
     * This method can be used to check if the logging during indexing should be done.
869
     * It takes the specific configuration by indexQueueConfiguration into account or is using the
870
     * fallback when the logging is enabled on queue or indexing level.
871
     *
872
     * plugin.tx_solr.logging.indexing.queue.<indexQueueConfiguration>
873
     *
874
     * @param string $indexQueueConfiguration
875
     * @param bool $defaultIfEmpty
876
     * @return bool
877
     */
878 13
    public function getLoggingIndexingQueueOperationsByConfigurationNameWithFallBack($indexQueueConfiguration, $defaultIfEmpty = false)
879
    {
880
        // when logging is globally enabled we do not need to check the specific configuration
881 13
        if ($this->getLoggingIndexing()) {
882 1
            return true;
883
        }
884
885
        // when the logging for indexing is enabled on queue level we also do not need to check the specific configuration
886 12
        if ($this->getLoggingIndexingQueue()) {
887
            return true;
888
        }
889
890 12
        $path = 'plugin.tx_solr.logging.indexing.queue.' . $indexQueueConfiguration;
891 12
        $result = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty);
892 12
        return $this->getBool($result);
893
    }
894
895
    /**
896
     * Returns if a log message should be written when a page was indexed.
897
     *
898
     * plugin.tx_solr.logging.indexing.pageIndexed
899
900
     * @param bool $defaultIfEmpty
901
     * @return bool
902
     */
903 5
    public function getLoggingIndexingPageIndexed($defaultIfEmpty = false)
904
    {
905 5
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing.pageIndexed', $defaultIfEmpty);
906 5
        return $this->getBool($result);
907
    }
908
909
    /**
910
     * Returns if a log message should be written when the TYPO3 search markers are missing in the page.
911
     *
912
     * plugin.tx_solr.logging.indexing.missingTypo3SearchMarkers
913
914
     * @param bool $defaultIfEmpty
915
     * @return bool
916
     */
917 6
    public function getLoggingIndexingMissingTypo3SearchMarkers($defaultIfEmpty = true)
918
    {
919 6
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing.missingTypo3SearchMarkers', $defaultIfEmpty);
920 6
        return $this->getBool($result);
921
    }
922
923
    /**
924
     * Returns if the initialization of an indexqueue should be logged.
925
     *
926
     * plugin.tx_solr.logging.indexing.indexQueueInitialization
927
     *
928
     * @param bool $defaultIfEmpty
929
     * @return bool
930
     */
931 7
    public function getLoggingIndexingIndexQueueInitialization($defaultIfEmpty = false)
932
    {
933 7
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing.indexQueueInitialization', $defaultIfEmpty);
934 7
        return $this->getBool($result);
935
    }
936
937
    /**
938
     * Indicates if the debug mode is enabled or not.
939
     *
940
     * plugin.tx_solr.enableDebugMode
941
942
     * @param bool $defaultIfEmpty
943
     * @return bool
944
     */
945 24
    public function getEnabledDebugMode($defaultIfEmpty = false)
946
    {
947 24
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.enableDebugMode', $defaultIfEmpty);
948 24
        return $this->getBool($result);
949
    }
950
951
    /**
952
     * Returns true or false if something is configured below plugin.tx_solr.solr.
953
     *
954
     * plugin.tx_solr.solr.
955
     *
956
     * @param boolean $defaultIfEmpty
957
     * @return boolean
958
     */
959 3
    public function getSolrHasConnectionConfiguration($defaultIfEmpty = false)
960
    {
961 3
        $configuration = $this->getObjectByPathOrDefault('plugin.tx_solr.solr.', []);
962 3
        return $configuration !== [] ? true : $defaultIfEmpty;
963
    }
964
965
    /**
966
     * Returns the defaultTimeout used for requests to the Solr server
967
     *
968
     * plugin.tx_solr.solr.timeout
969
     *
970
     * @param float $defaultIfEmpty
971
     * @return float
972
     */
973 74
    public function getSolrTimeout($defaultIfEmpty = 0.0)
974
    {
975 74
        return (float)$this->getValueByPathOrDefaultValue('plugin.tx_solr.solr.timeout', $defaultIfEmpty);
976
    }
977
978
    /**
979
     * Returns the scheme used for requests to the Solr server
980
     *
981
     * plugin.tx_solr.solr.scheme
982
     *
983
     * Applies stdWrap on the configured setting
984
     *
985
     * @param string $defaultIfEmpty
986
     * @return string
987
     */
988 4
    public function getSolrScheme($defaultIfEmpty = 'http')
989
    {
990 4
        $valuePath = 'plugin.tx_solr.solr.scheme';
991 4
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
992 4
        return $this->renderContentElementOfConfigured($valuePath, $value);
993
    }
994
995
    /**
996
     * Returns the hostname used for requests to the Solr server
997
     *
998
     * plugin.tx_solr.solr.host
999
     *
1000
     * Applies stdWrap on the configured setting
1001
     *
1002
     * @param string $defaultIfEmpty
1003
     * @return string
1004
     */
1005 7
    public function getSolrHost($defaultIfEmpty = 'localhost')
1006
    {
1007 7
        $valuePath = 'plugin.tx_solr.solr.host';
1008 7
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
1009 7
        return $this->renderContentElementOfConfigured($valuePath, $value);
1010
    }
1011
1012
    /**
1013
     * Returns the port used for requests to the Solr server
1014
     *
1015
     * plugin.tx_solr.solr.port
1016
     *
1017
     * Applies stdWrap on the configured setting
1018
     *
1019
     * @param int $defaultIfEmpty
1020
     * @return int
1021
     */
1022 4
    public function getSolrPort($defaultIfEmpty = 8983)
1023
    {
1024 4
        $valuePath = 'plugin.tx_solr.solr.port';
1025 4
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
1026 4
        return $this->renderContentElementOfConfigured($valuePath, $value);
1027
    }
1028
1029
    /**
1030
     * Returns the path used for requests to the Solr server
1031
     *
1032
     * plugin.tx_solr.solr.path
1033
     *
1034
     * Applies stdWrap on the configured setting
1035
     *
1036
     * @param string $defaultIfEmpty
1037
     * @return string
1038
     */
1039 7
    public function getSolrPath($defaultIfEmpty = '/solr/core_en/')
1040
    {
1041 7
        $valuePath = 'plugin.tx_solr.solr.path';
1042 7
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
1043 7
        $solrPath = $this->renderContentElementOfConfigured($valuePath, $value);
1044
1045 7
        $solrPath = trim($solrPath, '/');
1046 7
        $solrPath = '/' . $solrPath . '/';
1047
1048 7
        return $solrPath;
1049
    }
1050
1051
    /**
1052
     * Returns the username used for requests to the Solr server
1053
     *
1054
     * plugin.tx_solr.solr.username
1055
     *
1056
     * Applies stdWrap on the configured setting
1057
     *
1058
     * @param string $defaultIfEmpty
1059
     * @return string
1060
     */
1061 4
    public function getSolrUsername($defaultIfEmpty = '')
1062
    {
1063 4
        $valuePath = 'plugin.tx_solr.solr.username';
1064 4
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
1065 4
        return $this->renderContentElementOfConfigured($valuePath, $value);
1066
    }
1067
1068
    /**
1069
     * Returns the password used for requests to the Solr server
1070
     *
1071
     * plugin.tx_solr.solr.password
1072
     *
1073
     * Applies stdWrap on the configured setting
1074
     *
1075
     * @param string $defaultIfEmpty
1076
     * @return string
1077
     */
1078 4
    public function getSolrPassword($defaultIfEmpty = '')
1079
    {
1080 4
        $valuePath = 'plugin.tx_solr.solr.password';
1081 4
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
1082 4
        return $this->renderContentElementOfConfigured($valuePath, $value);
1083
    }
1084
1085
    /**
1086
     * Retrieves the complete search configuration
1087
     *
1088
     * plugin.tx_solr.search.
1089
     *
1090
     * @param array $defaultIfEmpty
1091
     * @return array
1092
     */
1093 24
    public function getSearchConfiguration(array $defaultIfEmpty = [])
1094
    {
1095 24
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.', $defaultIfEmpty);
1096 24
        return $result;
1097
    }
1098
1099
    /**
1100
     * Indicates if elevation should be used or not
1101
     *
1102
     * plugin.tx_solr.search.elevation
1103
     *
1104
     * @param bool $defaultIfEmpty
1105
     * @return bool
1106
     */
1107 24
    public function getSearchElevation($defaultIfEmpty = false)
1108
    {
1109 24
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.elevation', $defaultIfEmpty);
1110 24
        return $this->getBool($result);
1111
    }
1112
1113
    /**
1114
     * Indicates if elevated results should be marked
1115
     *
1116
     * plugin.tx_solr.search.elevation.markElevatedResults
1117
     *
1118
     * @param bool $defaultIfEmpty
1119
     * @return bool
1120
     */
1121 24
    public function getSearchElevationMarkElevatedResults($defaultIfEmpty = true)
1122
    {
1123 24
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.elevation.markElevatedResults', $defaultIfEmpty);
1124 24
        return $this->getBool($result);
1125
    }
1126
1127
    /**
1128
     * Indicates if elevation should be forced
1129
     *
1130
     *plugin.tx_solr.search.elevation.forceElevation
1131
     *
1132
     * @param bool $defaultIfEmpty
1133
     * @return bool
1134
     */
1135 24
    public function getSearchElevationForceElevation($defaultIfEmpty = true)
1136
    {
1137 24
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.elevation.forceElevation', $defaultIfEmpty);
1138 24
        return $this->getBool($result);
1139
    }
1140
1141
    /**
1142
     * Indicates if collapsing on a certain field should be used to build variants or not.
1143
     *
1144
     * plugin.tx_solr.search.variants
1145
     *
1146
     * @param bool $defaultIfEmpty
1147
     * @return bool
1148
     */
1149 130
    public function getSearchVariants($defaultIfEmpty = false)
1150
    {
1151 130
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.variants', $defaultIfEmpty);
1152 130
        return $this->getBool($result);
1153
    }
1154
1155
    /**
1156
     * Indicates if collapsing on a certain field should be used or not
1157
     *
1158
     * plugin.tx_solr.search.variants.variantField
1159
     *
1160
     * @param string $defaultIfEmpty
1161
     * @return string
1162
     */
1163 3
    public function getSearchVariantsField($defaultIfEmpty = 'variantId')
1164
    {
1165 3
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.variants.variantField', $defaultIfEmpty);
1166
    }
1167
1168
    /**
1169
     * Indicates if expanding of collapsed items it activated.
1170
     *
1171
     * plugin.tx_solr.search.variants.expand
1172
     *
1173
     * @param bool $defaultIfEmpty
1174
     * @return bool
1175
     */
1176 4
    public function getSearchVariantsExpand($defaultIfEmpty = false)
1177
    {
1178 4
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.variants.expand', $defaultIfEmpty);
1179 4
        return $this->getBool($result);
1180
    }
1181
1182
    /**
1183
     * Retrieves the number of elements that should be expanded.
1184
     *
1185
     * plugin.tx_solr.search.variants.limit
1186
     *
1187
     * @param int $defaultIfEmpty
1188
     * @return int
1189
     */
1190 2
    public function getSearchVariantsLimit($defaultIfEmpty = 10)
1191
    {
1192 2
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.variants.limit', $defaultIfEmpty);
1193 2
        return (int)$result;
1194
    }
1195
1196
    /**
1197
     * Indicates if frequent searches should be show or not.
1198
     *
1199
     * plugin.tx_solr.search.frequentSearches
1200
     *
1201
     * @param bool $defaultIfEmpty
1202
     * @return bool
1203
     */
1204 23
    public function getSearchFrequentSearches($defaultIfEmpty = false)
1205
    {
1206 23
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches', $defaultIfEmpty);
1207 23
        return $this->getBool($result);
1208
    }
1209
1210
    /**
1211
     * Returns the sub configuration of the frequentSearches
1212
     *
1213
     * plugin.tx_solr.search.frequentSearches.
1214
     *
1215
     * @param array $defaultIfEmpty
1216
     * @return array
1217
     */
1218 23
    public function getSearchFrequentSearchesConfiguration($defaultIfEmpty = [])
1219
    {
1220 23
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.frequentSearches.', $defaultIfEmpty);
1221 23
        return $result;
1222
    }
1223
1224
    /**
1225
     * Retrieves the minimum font size that should be used for the frequentSearches.
1226
     *
1227
     * plugin.tx_solr.search.frequentSearches.minSize
1228
     *
1229
     * @param int $defaultIfEmpty
1230
     * @return int
1231
     */
1232
    public function getSearchFrequentSearchesMinSize($defaultIfEmpty = 14)
1233
    {
1234
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches.minSize', $defaultIfEmpty);
1235
        return (int)$result;
1236
    }
1237
1238
    /**
1239
     * Retrieves the maximum font size that should be used for the frequentSearches.
1240
     *
1241
     * plugin.tx_solr.search.frequentSearches.minSize
1242
     *
1243
     * @param int $defaultIfEmpty
1244
     * @return int
1245
     */
1246
    public function getSearchFrequentSearchesMaxSize($defaultIfEmpty = 32)
1247
    {
1248
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches.maxSize', $defaultIfEmpty);
1249
        return (int)$result;
1250
    }
1251
1252
    /**
1253
     * Indicates if frequent searches should be show or not.
1254
     *
1255
     * plugin.tx_solr.search.frequentSearches.useLowercaseKeywords
1256
     *
1257
     * @param bool $defaultIfEmpty
1258
     * @return bool
1259
     */
1260 18
    public function getSearchFrequentSearchesUseLowercaseKeywords($defaultIfEmpty = false)
1261
    {
1262 18
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches.useLowercaseKeywords', $defaultIfEmpty);
1263 18
        return $this->getBool($result);
1264
    }
1265
1266
    /**
1267
     * Returns the configuration if the search should be initialized with an empty query.
1268
     *
1269
     * plugin.tx_solr.search.initializeWithEmptyQuery
1270
     *
1271
     * @param bool $defaultIfEmpty
1272
     * @return bool
1273
     */
1274 26
    public function getSearchInitializeWithEmptyQuery($defaultIfEmpty = false)
1275
    {
1276 26
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.initializeWithEmptyQuery', $defaultIfEmpty);
1277 26
        return $this->getBool($result);
1278
    }
1279
1280
    /**
1281
     * Returns the configured initial query
1282
     *
1283
     * plugin.tx_solr.search.initializeWithQuery
1284
     *
1285
     * @param string $defaultIfEmpty
1286
     * @return string
1287
     */
1288 26
    public function getSearchInitializeWithQuery($defaultIfEmpty = '')
1289
    {
1290 26
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.initializeWithQuery', $defaultIfEmpty);
1291 26
        return (string)$result;
1292
    }
1293
1294
    /**
1295
     * Returns if the last searches should be displayed or not.
1296
     *
1297
     * plugin.tx_solr.search.lastSearches
1298
     *
1299
     * @param bool $defaultIfEmpty
1300
     * @return bool
1301
     */
1302 23
    public function getSearchLastSearches($defaultIfEmpty = false)
1303
    {
1304 23
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.lastSearches', $defaultIfEmpty);
1305 23
        return $this->getBool($result);
1306
    }
1307
1308
    /**
1309
     * Returns the lastSearch mode. "user" for user specific
1310
     *
1311
     * plugin.tx_solr.search.lastSearches.mode
1312
     *
1313
     * @param string $defaultIfEmpty
1314
     * @return string
1315
     */
1316 23
    public function getSearchLastSearchesMode($defaultIfEmpty = 'user')
1317
    {
1318 23
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.lastSearches.mode', $defaultIfEmpty);
1319 23
        return (string)$result;
1320
    }
1321
1322
    /**
1323
     * Returns the lastSearch limit
1324
     *
1325
     * plugin.tx_solr.search.lastSearches.limit
1326
     *
1327
     * @param int $defaultIfEmpty
1328
     * @return int
1329
     */
1330 23
    public function getSearchLastSearchesLimit($defaultIfEmpty = 10)
1331
    {
1332 23
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.lastSearches.limit', $defaultIfEmpty);
1333 23
        return (int)$result;
1334
    }
1335
1336
    /**
1337
     * Returns the search results fieldProcessingInstructions configuration array
1338
     *
1339
     * plugin.tx_solr.search.results.fieldProcessingInstructions.
1340
     *
1341
     * @param array $defaultIfEmpty
1342
     * @return array
1343
     */
1344 18
    public function getSearchResultsFieldProcessingInstructionsConfiguration(array $defaultIfEmpty = [])
1345
    {
1346 18
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.results.fieldProcessingInstructions.', $defaultIfEmpty);
1347 18
        return $result;
1348
    }
1349
1350
    /**
1351
     * Returns the search results fieldRenderingInstructions configuration array
1352
     *
1353
     * plugin.tx_solr.search.results.fieldRenderingInstructions.
1354
     *
1355
     * @param array $defaultIfEmpty
1356
     * @return array
1357
     */
1358 18
    public function getSearchResultsFieldRenderingInstructionsConfiguration(array $defaultIfEmpty = [])
1359
    {
1360 18
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.results.fieldRenderingInstructions.', $defaultIfEmpty);
1361 18
        return $result;
1362
    }
1363
1364
    /**
1365
     * Indicates if the results of an initial empty query should be shown or not.
1366
     *
1367
     * plugin.tx_solr.search.showResultsOfInitialEmptyQuery
1368
     *
1369
     * @param bool $defaultIfEmpty
1370
     * @return bool
1371
     */
1372 4
    public function getSearchShowResultsOfInitialEmptyQuery($defaultIfEmpty = false)
1373
    {
1374 4
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.showResultsOfInitialEmptyQuery', $defaultIfEmpty);
1375 4
        return $this->getBool($result);
1376
    }
1377
1378
    /**
1379
     * Indicates if the results of an initial search query should be shown.
1380
     *
1381
     * plugin.tx_solr.search.showResultsOfInitialQuery
1382
     *
1383
     * @param bool $defaultIfEmpty
1384
     * @return bool
1385
     */
1386 4
    public function getSearchShowResultsOfInitialQuery($defaultIfEmpty = false)
1387
    {
1388 4
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.showResultsOfInitialQuery', $defaultIfEmpty);
1389 4
        return $this->getBool($result);
1390
    }
1391
1392
    /**
1393
     * Indicates if sorting was enabled or not.
1394
     *
1395
     * plugin.tx_solr.search.sorting
1396
     *
1397
     * @param bool $defaultIfEmpty
1398
     * @return bool
1399
     */
1400 17
    public function getSearchSorting($defaultIfEmpty = false)
1401
    {
1402 17
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.sorting', $defaultIfEmpty);
1403 17
        return $this->getBool($result);
1404
    }
1405
1406
    /**
1407
     * Returns the sorting options configurations.
1408
     *
1409
     * plugin.tx_solr.search.sorting.options.
1410
     *
1411
     * @param array $defaultIfEmpty
1412
     * @return array
1413
     */
1414 17
    public function getSearchSortingOptionsConfiguration($defaultIfEmpty = [])
1415
    {
1416 17
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.sorting.options.', $defaultIfEmpty);
1417 17
        return $result;
1418
    }
1419
1420
    /**
1421
     * Retrieves the sorting default order for a sort option.
1422
     *
1423
     * plugin.tx_solr.search.sorting.options.<sortOptionName>.defaultOrder
1424
     *
1425
     * or
1426
     *
1427
     * plugin.tx_solr.search.sorting.defaultOrder
1428
     *
1429
     *
1430
     * @param string $sortOptionName
1431
     * @param string $defaultIfEmpty
1432
     * @return string
1433
     */
1434 17
    public function getSearchSortingDefaultOrderBySortOptionName($sortOptionName = '', $defaultIfEmpty = 'asc')
1435
    {
1436 17
        $sortOrderSpecificPath = 'plugin.tx_solr.search.sorting.options.' . $sortOptionName . '.defaultOrder';
1437 17
        $specificSortOrder = $this->getValueByPathOrDefaultValue($sortOrderSpecificPath, null);
1438
1439
        // if we have a concrete setting, use it
1440 17
        if ($specificSortOrder !== null) {
1441
            return $specificSortOrder;
1442
        }
1443
1444
        // no specific setting, check common setting
1445 17
        $commonPath = 'plugin.tx_solr.search.sorting.defaultOrder';
1446 17
        $commonATagParamOrDefaultValue = $this->getValueByPathOrDefaultValue($commonPath, $defaultIfEmpty);
1447 17
        return $commonATagParamOrDefaultValue;
1448
    }
1449
1450
    /**
1451
     * Returns the configured fixedOrder, if nothing configured defaultIfEmpty will be returned.
1452
     *
1453
     * plugin.tx_solr.search.sorting.options.<sortOptionName>.fixedOrder
1454
     *
1455
     * @param string $sortOptionName
1456
     * @param string $defaultIfEmpty
1457
     * @return string
1458
     */
1459 17
    public function getSearchSortingFixedOrderBySortOptionName($sortOptionName = '', $defaultIfEmpty = '')
1460
    {
1461 17
        $fixedOrder = 'plugin.tx_solr.search.sorting.options.' . $sortOptionName . '.fixedOrder';
1462 17
        return $this->getValueByPathOrDefaultValue($fixedOrder, $defaultIfEmpty);
1463
    }
1464
1465
    /**
1466
     * Returns the trusted fields configured for the search that do not need to be escaped.
1467
     *
1468
     * @param array $defaultIfEmpty
1469
     * @return array
1470
     */
1471 18
    public function getSearchTrustedFieldsArray($defaultIfEmpty = ['url'])
1472
    {
1473 18
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.trustedFields', '');
1474
1475 18
        if (trim($result) === '') {
1476
            return $defaultIfEmpty;
1477
        }
1478
1479 18
        return GeneralUtility::trimExplode(',', $result);
1480
    }
1481
1482
    /**
1483
     * Indicates if the plugin arguments should be kept in the search form for a second submission.
1484
     *
1485
     * plugin.tx_solr.search.keepExistingParametersForNewSearches
1486
     *
1487
     * @param bool $defaultIfEmpty
1488
     * @return bool
1489
     */
1490 23
    public function getSearchKeepExistingParametersForNewSearches($defaultIfEmpty = false)
1491
    {
1492 23
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.keepExistingParametersForNewSearches', $defaultIfEmpty);
1493 23
        return $this->getBool($result);
1494
    }
1495
1496
    /**
1497
     * Returns if an empty query is allowed on the query level.
1498
     *
1499
     * plugin.tx_solr.search.query.allowEmptyQuery
1500
     *
1501
     * @param string $defaultIfEmpty
1502
     * @return bool
1503
     */
1504 26
    public function getSearchQueryAllowEmptyQuery($defaultIfEmpty = '')
1505
    {
1506 26
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.allowEmptyQuery', $defaultIfEmpty);
1507 26
        return $this->getBool($result);
1508
    }
1509
1510
    /**
1511
     * Returns the fieldProcessingInstructions configuration array
1512
     *
1513
     * plugin.tx_solr.search.query.filter.
1514
     *
1515
     * @param array $defaultIfEmpty
1516
     * @return array
1517
     */
1518 32
    public function getSearchQueryFilterConfiguration(array $defaultIfEmpty = [])
1519
    {
1520 32
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.query.filter.', $defaultIfEmpty);
1521 32
        return $result;
1522
    }
1523
1524
    /**
1525
     * Can be used to overwrite the filterConfiguration.
1526
     *
1527
     * plugin.tx_solr.search.query.filter.
1528
     *
1529
     * @param array $configuration
1530
     */
1531 1
    public function setSearchQueryFilterConfiguration(array $configuration)
1532
    {
1533 1
        $this->configurationAccess->set('plugin.tx_solr.search.query.filter.', $configuration);
1534 1
    }
1535
1536
    /**
1537
     * Removes the pageSections filter setting.
1538
     *
1539
     * @return void
1540
     */
1541 2
    public function removeSearchQueryFilterForPageSections()
1542
    {
1543 2
        $this->configurationAccess->reset('plugin.tx_solr.search.query.filter.__pageSections');
1544 2
    }
1545
1546
    /**
1547
     * Returns the configured queryFields from TypoScript
1548
     *
1549
     * plugin.tx_solr.search.query.queryFields
1550
     *
1551
     * @param string $defaultIfEmpty
1552
     * @return string
1553
     */
1554 131
    public function getSearchQueryQueryFields($defaultIfEmpty = '')
1555
    {
1556 131
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.queryFields', $defaultIfEmpty);
1557
    }
1558
1559
    /**
1560
     * Returns the configured returnFields as array.
1561
     *
1562
     * plugin.tx_solr.search.query.returnFields
1563
     *
1564
     * @param array $defaultIfEmpty
1565
     * @return array
1566
     */
1567 131
    public function getSearchQueryReturnFieldsAsArray($defaultIfEmpty = [])
1568
    {
1569 131
        $returnFields = $this->getValueByPath('plugin.tx_solr.search.query.returnFields');
1570 131
        if (is_null($returnFields)) {
1571 105
            return $defaultIfEmpty;
1572
        }
1573 26
        return GeneralUtility::trimExplode(',', $returnFields);
0 ignored issues
show
Documentation introduced by
$returnFields is of type array, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
1574
    }
1575
1576
    /**
1577
     * Returns the configured target page for the search.
1578
     * By default the contextPageId will be used
1579
     *
1580
     * plugin.tx_solr.search.targetPage
1581
     *
1582
     * @return int
1583
     */
1584 136
    public function getSearchTargetPage()
1585
    {
1586 136
        $targetPage = (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.targetPage', 0);
1587 136
        if ($targetPage === 0) {
1588
            // when no specific page was configured we use the contextPageId (which is usual $GLOBALS['TSFE']->id)
1589 83
            $targetPage = $this->contextPageId;
1590
        }
1591
1592 136
        return $targetPage;
1593
    }
1594
1595
    /**
1596
     * Retrieves the targetPage configuration.
1597
     *
1598
     * plugin.tx_solr.search.targetPage.
1599
     *
1600
     * @param array $defaultIfEmpty
1601
     * @return array
1602
     */
1603 28
    public function getSearchTargetPageConfiguration(array $defaultIfEmpty = [])
1604
    {
1605 28
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.targetPage.', $defaultIfEmpty);
1606 28
        return $result;
1607
    }
1608
1609
    /**
1610
     * Retrieves the pagebrowser configuration.
1611
     *
1612
     * plugin.tx_solr.search.results.pagebrowser.
1613
     *
1614
     * @param array $defaultIfEmpty
1615
     * @return array
1616
     */
1617 18
    public function getSearchResultsPageBrowserConfiguration(array $defaultIfEmpty = [])
1618
    {
1619 18
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.results.pagebrowser.', $defaultIfEmpty);
1620 18
        return $result;
1621
    }
1622
1623
    /**
1624
     * Returns the result highlighting fields.
1625
     *
1626
     * plugin.tx_solr.search.results.resultsHighlighting.highlightFields
1627
     *
1628
     * @param string $defaultIfEmpty
1629
     * @return string
1630
     */
1631 31
    public function getSearchResultsHighlightingFields($defaultIfEmpty = '')
1632
    {
1633 31
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsHighlighting.highlightFields', $defaultIfEmpty);
1634
    }
1635
1636
    /**
1637
     * Returns the result highlighting fields as array.
1638
     *
1639
     * plugin.tx_solr.search.results.resultsHighlighting.highlightFields
1640
     *
1641
     * @param array $defaultIfEmpty
1642
     * @return array
1643
     */
1644 18
    public function getSearchResultsHighlightingFieldsAsArray($defaultIfEmpty = [])
1645
    {
1646 18
        $highlightingFields = $this->getSearchResultsHighlightingFields('');
1647
1648 18
        if ($highlightingFields === '') {
1649
            return $defaultIfEmpty;
1650
        }
1651
1652 18
        return GeneralUtility::trimExplode(',', $highlightingFields, true);
1653
    }
1654
1655
    /**
1656
     * Returns the fragmentSeparator for highlighted segments.
1657
     *
1658
     * plugin.tx_solr.search.results.resultsHighlighting.fragmentSeparator
1659
     *
1660
     * @param string $defaultIfEmpty
1661
     * @return string
1662
     */
1663 18
    public function getSearchResultsHighlightingFragmentSeparator($defaultIfEmpty = '[...]')
1664
    {
1665 18
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsHighlighting.fragmentSeparator', $defaultIfEmpty);
1666
    }
1667
1668
    /**
1669
     * Returns the number of results that should be shown per page.
1670
     *
1671
     * plugin.tx_solr.search.results.resultsPerPage
1672
     *
1673
     * @param int $defaultIfEmpty
1674
     * @return int
1675
     */
1676 24
    public function getSearchResultsPerPage($defaultIfEmpty = 10)
1677
    {
1678 24
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsPerPage', $defaultIfEmpty);
1679
    }
1680
1681
    /**
1682
     * Returns the available options for the per page switch.
1683
     *
1684
     * plugin.tx_solr.search.results.resultsPerPageSwitchOptions
1685
     *
1686
     * @param array $defaultIfEmpty
1687
     * @return array
1688
     */
1689 24
    public function getSearchResultsPerPageSwitchOptionsAsArray($defaultIfEmpty = [])
1690
    {
1691 24
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsPerPageSwitchOptions', '');
1692
1693 24
        if (trim($result) === '') {
1694
            return $defaultIfEmpty;
1695
        }
1696
1697 24
        return GeneralUtility::intExplode(',', $result, true);
1698
    }
1699
1700
    /**
1701
     * Returns the configured wrap for the resultHighlighting.
1702
     *
1703
     * plugin.tx_solr.search.results.resultsHighlighting.wrap
1704
     *
1705
     * @param string $defaultIfEmpty
1706
     * @return string
1707
     */
1708 31
    public function getSearchResultsHighlightingWrap($defaultIfEmpty = '')
1709
    {
1710 31
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsHighlighting.wrap', $defaultIfEmpty);
1711
    }
1712
1713
    /**
1714
     * Indicates if spellchecking is enabled or not.
1715
     *
1716
     * plugin.tx_solr.search.spellchecking
1717
     *
1718
     * @param bool $defaultIfEmpty
1719
     * @return bool
1720
     */
1721 25
    public function getSearchSpellchecking($defaultIfEmpty = false)
1722
    {
1723 25
        $isFacetingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking', $defaultIfEmpty);
1724 25
        return $this->getBool($isFacetingEnabled);
1725
    }
1726
1727
    /**
1728
     * Returns the wrap that should be used for spellchecking
1729
     *
1730
     * plugin.tx_solr.search.spellchecking.wrap
1731
     *
1732
     * @param string $defaultIfEmpty
1733
     * @return string
1734
     */
1735 5
    public function getSearchSpellcheckingWrap($defaultIfEmpty = '')
1736
    {
1737 5
        return (string)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking.wrap', $defaultIfEmpty);
1738
    }
1739
1740
    /**
1741
     * Returns the numberOfSuggestionsToTry that should be used for the spellchecking.
1742
     *
1743
     * plugin.tx_solr.search.spellchecking.numberOfSuggestionsToTry
1744
     *
1745
     * @param int $defaultIfEmpty
1746
     * @return int
1747
     */
1748 22
    public function getSearchSpellcheckingNumberOfSuggestionsToTry($defaultIfEmpty = 0)
1749
    {
1750 22
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking.numberOfSuggestionsToTry', $defaultIfEmpty);
1751
    }
1752
1753
    /**
1754
     * Indicates if a second search should be fired from the spellchecking suggestion if no results could be found.
1755
     *
1756
     * plugin.tx_solr.search.spellchecking.searchUsingSpellCheckerSuggestion
1757
     *
1758
     * @param bool $defaultIfEmpty
1759
     * @return bool
1760
     */
1761 3
    public function getSearchSpellcheckingSearchUsingSpellCheckerSuggestion($defaultIfEmpty = false)
1762
    {
1763 3
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking.searchUsingSpellCheckerSuggestion', $defaultIfEmpty);
1764 3
        return $this->getBool($result);
1765
    }
1766
1767
    /**
1768
     * Indicates if faceting is enabled or not.
1769
     *
1770
     * plugin.tx_solr.search.faceting
1771
     *
1772
     * @param bool $defaultIfEmpty
1773
     * @return bool
1774
     */
1775 20
    public function getSearchFaceting($defaultIfEmpty = false)
1776
    {
1777 20
        $isFacetingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting', $defaultIfEmpty);
1778 20
        return $this->getBool($isFacetingEnabled);
1779
    }
1780
1781
    /**
1782
     * Retrieves the facetLinkATagParams for a facet by facet name. If nothing specific is configured
1783
     * the global facetLinkATagParams with be returned.
1784
     *
1785
     * plugin.tx_solr.search.faceting.facets.<facetName>.facetLinkATagParams
1786
     *
1787
     * or
1788
     *
1789
     * plugin.tx_solr.search.faceting.facetLinkATagParams
1790
     *
1791
     *
1792
     * @param string $facetName
1793
     * @param string $defaultIfEmpty
1794
     * @return string
1795
     */
1796 19
    public function getSearchFacetingFacetLinkATagParamsByName($facetName = '', $defaultIfEmpty = '')
1797
    {
1798 19
        $facetSpecificPath = 'plugin.tx_solr.search.faceting.facets.' . $facetName . '.facetLinkATagParams';
1799 19
        $specificATagParam = $this->getValueByPathOrDefaultValue($facetSpecificPath, null);
1800
1801
            // if we have a concrete setting, use it
1802 19
        if ($specificATagParam !== null) {
1803 1
            return $specificATagParam;
1804
        }
1805
1806
            // no specific setting, check common setting
1807 19
        $commonPath = 'plugin.tx_solr.search.faceting.facetLinkATagParams';
1808 19
        $commonATagParamOrDefaultValue = $this->getValueByPathOrDefaultValue($commonPath, $defaultIfEmpty);
1809 19
        return $commonATagParamOrDefaultValue;
1810
    }
1811
1812
    /**
1813
     * Returns the test that should be used to remove a faceting link
1814
     *
1815
     * plugin.tx_solr.search.faceting.removeFacetLinkText
1816
     *
1817
     * @param string $defaultIfEmpty
1818
     * @return string
1819
     */
1820 1
    public function getSearchFacetingRemoveFacetLinkText($defaultIfEmpty = '@facetLabel: @facetText')
1821
    {
1822 1
        return (string)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.removeFacetLinkText', $defaultIfEmpty);
1823
    }
1824
1825
    /**
1826
     * Retrieves the showEvenWhenEmpty for a facet by facet name. If nothing specific is configured
1827
     * the global showEmptyFacets with be returned.
1828
     *
1829
     * plugin.tx_solr.search.faceting.facets.<facetName>.showEvenWhenEmpty
1830
     *
1831
     * or
1832
     *
1833
     * plugin.tx_solr.search.faceting.showEmptyFacets
1834
     *
1835
     *
1836
     * @param string $facetName
1837
     * @param bool $defaultIfEmpty
1838
     * @return bool
1839
     */
1840 19
    public function getSearchFacetingShowEmptyFacetsByName($facetName = '', $defaultIfEmpty = false)
1841
    {
1842 19
        $facetSpecificPath = 'plugin.tx_solr.search.faceting.facets.' . $facetName . '.showEvenWhenEmpty';
1843 19
        $specificShowWhenEmpty = $this->getValueByPathOrDefaultValue($facetSpecificPath, null);
1844
1845
        // if we have a concrete setting, use it
1846 19
        if ($specificShowWhenEmpty !== null) {
1847 1
            return $specificShowWhenEmpty;
1848
        }
1849
1850
        // no specific setting, check common setting
1851 19
        $commonPath = 'plugin.tx_solr.search.faceting.showEmptyFacets';
1852 19
        $commonIfEmptyOrDefaultValue = $this->getValueByPathOrDefaultValue($commonPath, $defaultIfEmpty);
1853 19
        return $commonIfEmptyOrDefaultValue;
1854
    }
1855
1856
    /**
1857
     * Returns the wrap for the faceting show all link
1858
     *
1859
     * plugin.tx_solr.search.faceting.showAllLink.wrap
1860
     *
1861
     * @param string $defaultIfEmpty
1862
     * @return string
1863
     */
1864
    public function getSearchFacetingShowAllLinkWrap($defaultIfEmpty = '')
1865
    {
1866
        return (string)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.showAllLink.wrap', $defaultIfEmpty);
1867
    }
1868
1869
    /**
1870
     * Returns the link url parameters that should be added to a facet.
1871
     *
1872
     * plugin.tx_solr.search.faceting.facetLinkUrlParameters
1873
     *
1874
     * @param string $defaultIfEmpty
1875
     * @return string
1876
     */
1877 18
    public function getSearchFacetingFacetLinkUrlParameters($defaultIfEmpty = '')
1878
    {
1879 18
        $linkUrlParameters = trim($this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.facetLinkUrlParameters', $defaultIfEmpty));
1880
1881 18
        return $linkUrlParameters;
1882
    }
1883
1884
    /**
1885
     * Returns if the facetLinkUrlsParameters should be included in the reset link.
1886
     *
1887
     * plugin.tx_solr.search.faceting.facetLinkUrlParameters.useForFacetResetLinkUrl
1888
     *
1889
     * @param bool $defaultIfEmpty
1890
     * @return bool
1891
     */
1892 18
    public function getSearchFacetingFacetLinkUrlParametersUseForFacetResetLinkUrl($defaultIfEmpty = true)
1893
    {
1894 18
        $useForFacetResetLinkUrl = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.facetLinkUrlParameters.useForFacetResetLinkUrl', $defaultIfEmpty);
1895 18
        return $this->getBool($useForFacetResetLinkUrl);
1896
    }
1897
1898
    /**
1899
     * Returns the link url parameters that should be added to a facet as array.
1900
     *
1901
     * plugin.tx_solr.search.faceting.facetLinkUrlParameters
1902
     *
1903
     * @param array $defaultIfEmpty
1904
     * @return array
1905
     */
1906 18
    public function getSearchFacetingFacetLinkUrlParametersAsArray($defaultIfEmpty = [])
1907
    {
1908 18
        $linkUrlParameters = $this->getSearchFacetingFacetLinkUrlParameters();
1909 18
        if ($linkUrlParameters === '') {
1910
            return $defaultIfEmpty;
1911
        }
1912
1913 18
        return GeneralUtility::explodeUrl2Array($linkUrlParameters);
1914
    }
1915
1916
    /**
1917
     * Return the configured minimumCount value for facets.
1918
     *
1919
     * plugin.tx_solr.search.faceting.minimumCount
1920
     *
1921
     * @param int $defaultIfEmpty
1922
     * @return int
1923
     */
1924 31
    public function getSearchFacetingMinimumCount($defaultIfEmpty = 1)
1925
    {
1926 31
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.minimumCount', $defaultIfEmpty);
1927
    }
1928
1929
    /**
1930
     * Return the configured limit value for facets, used for displaying.
1931
     *
1932
     * plugin.tx_solr.search.faceting.limit
1933
     *
1934
     * @param int $defaultIfEmpty
1935
     * @return int
1936
     */
1937 18
    public function getSearchFacetingLimit($defaultIfEmpty = 10)
1938
    {
1939 18
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.limit', $defaultIfEmpty);
1940
    }
1941
1942
    /**
1943
     * Return the configured limit value for facets, used for the response.
1944
     *
1945
     * plugin.tx_solr.search.faceting.facetLimit
1946
     *
1947
     * @param int $defaultIfEmpty
1948
     * @return int
1949
     */
1950 31
    public function getSearchFacetingFacetLimit($defaultIfEmpty = 100)
1951
    {
1952 31
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.facetLimit', $defaultIfEmpty);
1953
    }
1954
1955
    /**
1956
     * Returns if the singleFacetMode is active or not.
1957
     *
1958
     * plugin.tx_solr.search.faceting.singleFacetMode
1959
     *
1960
     * @param bool $defaultIfEmpty
1961
     * @return bool
1962
     */
1963 1
    public function getSearchFacetingSingleFacetMode($defaultIfEmpty = false)
1964
    {
1965 1
        $singleFacetMode = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.singleFacetMode', $defaultIfEmpty);
1966 1
        return $this->getBool($singleFacetMode);
1967
    }
1968
1969
    /**
1970
     * Return the configured faceting sortBy value.
1971
     *
1972
     * plugin.tx_solr.search.faceting.sortBy
1973
     *
1974
     * @param string $defaultIfEmpty
1975
     * @return string
1976
     */
1977 31
    public function getSearchFacetingSortBy($defaultIfEmpty = '')
1978
    {
1979 31
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.sortBy', $defaultIfEmpty);
1980
    }
1981
1982
    /**
1983
     * Returns if a facets should be kept on selection. Global faceting setting
1984
     * can also be configured on facet level by using
1985
     * (plugin.tx_solr.search.faceting.facets.<fieldName>.keepAllOptionsOnSelection)
1986
     *
1987
     * plugin.tx_solr.search.faceting.keepAllFacetsOnSelection
1988
     *
1989
     * @param bool $defaultIfEmpty
1990
     * @return bool
1991
     */
1992 27
    public function getSearchFacetingKeepAllFacetsOnSelection($defaultIfEmpty = false)
1993
    {
1994 27
        $keepAllOptionsOnSelection = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.keepAllFacetsOnSelection', $defaultIfEmpty);
1995 27
        return $this->getBool($keepAllOptionsOnSelection);
1996
    }
1997
1998
    /**
1999
     * Returns the configured faceting configuration.
2000
     *
2001
     * plugin.tx_solr.search.faceting.facets
2002
     *
2003
     * @param array $defaultIfEmpty
2004
     * @return array
2005
     */
2006 27
    public function getSearchFacetingFacets(array $defaultIfEmpty = [])
2007
    {
2008 27
        return $this->getObjectByPathOrDefault('plugin.tx_solr.search.faceting.facets.', $defaultIfEmpty);
2009
    }
2010
2011
    /**
2012
     * Returns the configuration of a single facet by facet name.
2013
     *
2014
     * plugin.tx_solr.search.faceting.facets.<facetName>
2015
     *
2016
     * @param string $facetName
2017
     * @param array $defaultIfEmpty
2018
     * @return array
2019
     */
2020 18
    public function getSearchFacetingFacetByName($facetName, $defaultIfEmpty = [])
2021
    {
2022 18
        return $this->getObjectByPathOrDefault('plugin.tx_solr.search.faceting.facets.' . $facetName . '.', $defaultIfEmpty);
2023
    }
2024
2025
    /**
2026
     * Indicates if statistics is enabled or not.
2027
     *
2028
     * plugin.tx_solr.statistics
2029
     *
2030
     * @param bool $defaultIfEmpty
2031
     * @return bool
2032
     */
2033 24
    public function getStatistics($defaultIfEmpty = false)
2034
    {
2035 24
        $isStatisticsEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.statistics', $defaultIfEmpty);
2036 24
        return $this->getBool($isStatisticsEnabled);
2037
    }
2038
2039
    /**
2040
     * Indicates to which length an ip should be anonymized in the statistics
2041
     *
2042
     * plugin.tx_solr.statistics.anonymizeIP
2043
     *
2044
     * @param int $defaultIfEmpty
2045
     * @return int
2046
     */
2047 18
    public function getStatisticsAnonymizeIP($defaultIfEmpty = 0)
2048
    {
2049 18
        $anonymizeToLength = $this->getValueByPathOrDefaultValue('plugin.tx_solr.statistics.anonymizeIP', $defaultIfEmpty);
2050 18
        return (int)$anonymizeToLength;
2051
    }
2052
2053
    /**
2054
     * Indicates if additional debug Data should be added to the statistics
2055
     *
2056
     * plugin.tx_solr.statistics.addDebugData
2057
     *
2058
     * @param bool $defaultIfEmpty
2059
     * @return bool
2060
     */
2061 20
    public function getStatisticsAddDebugData($defaultIfEmpty = false)
2062
    {
2063 20
        $statisticsAddDebugDataEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.statistics.addDebugData', $defaultIfEmpty);
2064 20
        return $this->getBool($statisticsAddDebugDataEnabled);
2065
    }
2066
2067
    /**
2068
     * Indicates if suggestion is enabled or not.
2069
     *
2070
     * plugin.tx_solr.suggest
2071
     *
2072
     * @param bool $defaultIfEmpty
2073
     * @return bool
2074
     */
2075 25
    public function getSuggest($defaultIfEmpty = false)
2076
    {
2077 25
        $isSuggestionEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest', $defaultIfEmpty);
2078 25
        return $this->getBool($isSuggestionEnabled);
2079
    }
2080
2081
    /**
2082
     * Indicates if https should be used for the suggest form.
2083
     *
2084
     * plugin.tx_solr.suggest.forceHttps
2085
     *
2086
     * @param bool $defaultIfEmpty
2087
     * @return bool
2088
     */
2089 25
    public function getSuggestForceHttps($defaultIfEmpty = false)
2090
    {
2091 25
        $isHttpsForced = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest.forceHttps', $defaultIfEmpty);
2092 25
        return $this->getBool($isHttpsForced);
2093
    }
2094
2095
    /**
2096
     * Returns the configured template for a specific template fileKey.
2097
     *
2098
     * plugin.tx_solr.search.templateFiles.<fileKey>
2099
     *
2100
     * @param string $fileKey
2101
     * @param string $defaultIfEmpty
2102
     * @return string
2103
     */
2104 25
    public function getTemplateByFileKey($fileKey, $defaultIfEmpty = '')
2105
    {
2106 25
        $templateFileName = $this->getValueByPathOrDefaultValue('plugin.tx_solr.templateFiles.' . $fileKey, $defaultIfEmpty);
2107 25
        return (string)$templateFileName;
2108
    }
2109
2110
    /**
2111
     * Returns the configuration of the crop view helper.
2112
     *
2113
     * plugin.tx_solr.viewHelpers.crop.
2114
     *
2115
     * @param array $defaultIfEmpty
2116
     * @return array
2117
     */
2118 1
    public function getViewHelpersCropConfiguration(array $defaultIfEmpty = [])
2119
    {
2120 1
        $cropViewHelperConfiguration = $this->getObjectByPathOrDefault('plugin.tx_solr.viewHelpers.crop.', $defaultIfEmpty);
2121 1
        return $cropViewHelperConfiguration;
2122
    }
2123
2124
    /**
2125
     * Returns the configuration of the sorting view helper.
2126
     *
2127
     * plugin.tx_solr.viewHelpers.sortIndicator.
2128
     *
2129
     * @param array $defaultIfEmpty
2130
     * @return array
2131
     */
2132 17
    public function getViewHelpersSortIndicatorConfiguration(array $defaultIfEmpty = [])
2133
    {
2134 17
        $sortingViewHelperConfiguration = $this->getObjectByPathOrDefault('plugin.tx_solr.viewHelpers.sortIndicator.', $defaultIfEmpty);
2135 17
        return $sortingViewHelperConfiguration;
2136
    }
2137
2138
    /**
2139
     * Controls whether ext-solr will send commits to solr.
2140
     * Beware: If you disable this, you need to ensure
2141
     * that some other mechanism will commit your changes
2142
     * otherwise they will never be searchable.
2143
     * A good way to achieve this is enabling the solr
2144
     * daemons autoCommit feature.
2145
     *
2146
     * plugin.tx_solr.index.enableCommits
2147
     *
2148
     * @param bool $defaultIfEmpty
2149
     * @return bool
2150
     */
2151 11
    public function getEnableCommits($defaultIfEmpty = true)
2152
    {
2153 11
        $enableCommits = $this->getValueByPathOrDefaultValue('plugin.tx_solr.index.enableCommits', $defaultIfEmpty);
2154 11
        return $this->getBool($enableCommits);
2155
    }
2156
2157
    /*
2158
     * Applies the stdWrap if it is configured for the path, otherwise the unprocessed value will be returned.
2159
     *
2160
     * @param string $valuePath
2161
     * @param mixed $value
2162
     * @return mixed
2163
     */
2164 7
    protected function renderContentElementOfConfigured($valuePath, $value)
2165
    {
2166 7
        $configurationPath = $valuePath . '.';
2167 7
        $configuration = $this->getObjectByPath($configurationPath);
2168
2169 7
        if ($configuration == null) {
2170 5
            return $value;
2171
        }
2172
2173 2
        return $this->contentObjectService->renderSingleContentObject($value, $configuration);
2174
    }
2175
}
2176