Completed
Push — master ( a30450...a106a1 )
by
unknown
42s
created

getIndexQueueConfigurationRecursiveUpdateFields()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 2
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 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 215
    public function __construct(array $configuration, $contextPageId = 0, ContentObjectService $contentObjectService = null)
87
    {
88 215
        $this->configurationAccess = new ArrayAccessor($configuration, '.', true);
89 215
        $this->contextPageId = $contextPageId;
90 215
        $this->contentObjectService = is_null($contentObjectService) ? GeneralUtility::makeInstance(ContentObjectService::class) : $contentObjectService;
91 215
    }
92
93
    /**
94
     * Checks if a value is 1, '1', 'true'
95
     * @param mixed $value
96
     * @return bool
97
     */
98 197
    protected function getBool($value)
99
    {
100 197
        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 234
    public function getValueByPath($path)
144
    {
145 234
        if (!is_string($path)) {
146
            throw new InvalidArgumentException('Parameter $path is not a string',
147
                1325623321);
148
        }
149
150 234
        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 233
    public function getValueByPathOrDefaultValue($path, $defaultValue)
162
    {
163 233
        $value = $this->getValueByPath($path);
164 233
        if (is_null($value)) {
165 216
            return $defaultValue;
166
        }
167
168 158
        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 122
    public function getObjectByPath($path)
188
    {
189 122
        if (substr($path, -1) !== '.') {
190 4
            $path = rtrim($path, '.');
191 4
            $path = substr($path, 0, strrpos($path, '.') + 1);
192
        }
193
194 122
        if (!is_string($path)) {
195
            throw new InvalidArgumentException('Parameter $path is not a string', 1325627243);
196
        }
197
198 122
        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 114
    public function getObjectByPathOrDefault($path, array $defaultValue)
211
    {
212
        try {
213 114
            $object = $this->getObjectByPath($path);
214
        } catch (\InvalidArgumentException $e) {
215
            return $defaultValue;
216
        }
217
218 114
        if (!is_array($object)) {
219 41
            return $defaultValue;
220
        }
221
222 103
        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 36
    public function getIndexQueueTableNameOrFallbackToConfigurationName($configurationName = '')
425
    {
426 36
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.table';
427 36
        $result = $this->getValueByPathOrDefaultValue($path, $configurationName);
428 36
        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 24
    public function getIndexQueueConfigurationIsEnabled($configurationName, $defaultIfEmpty = false)
542
    {
543 24
        $path = 'plugin.tx_solr.index.queue.' . $configurationName;
544 24
        $result = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty);
545 24
        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 31
    public function getEnabledIndexQueueConfigurationNames($defaultIfEmpty = [])
557
    {
558 31
        $tablesToIndex = [];
559 31
        $path = 'plugin.tx_solr.index.queue.';
560 31
        $indexQueueConfiguration = $this->getObjectByPathOrDefault($path, []);
561 31
        foreach ($indexQueueConfiguration as $configurationName => $indexingEnabled) {
562 31
            if (substr($configurationName, -1) != '.' && $indexingEnabled) {
563 31
                $tablesToIndex[] = $configurationName;
564
            }
565
        }
566
567 31
        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.pages.initialPagesAdditionalWhereClause
597
     *
598
     * @param string $defaultIfEmpty
599
     *
600
     * @return string
601
     *
602
     */
603 8
    public function getInitialPagesAdditionalWhereClause($defaultIfEmpty = ' AND 1=1')
604
    {
605 8
        $path = 'plugin.tx_solr.index.queue.pages' . '.initialPagesAdditionalWhereClause';
606 8
        $initialPagesAdditionalWhereClause = $this->getValueByPathOrDefaultValue($path, '');
607
608 8
        if (trim($initialPagesAdditionalWhereClause) === '') {
609 8
            return $defaultIfEmpty;
610
        }
611
612
        return ' AND ' . $initialPagesAdditionalWhereClause;
613
    }
614
615
    /**
616
     * Retrieves and additional where clause when configured or an empty string.
617
     *
618
     * plugin.tx_solr.index.queue.<configurationName>.additionalWhereClause
619
     *
620
     * @param string $configurationName
621
     * @return string
622
     */
623 42
    public function getIndexQueueAdditionalWhereClauseByConfigurationName($configurationName)
624
    {
625 42
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.additionalWhereClause';
626 42
        $additionalWhere = $this->getValueByPathOrDefaultValue($path, '');
627
628 42
        if (trim($additionalWhere) == '') {
629 11
            return '';
630
        }
631
632 32
        return ' AND ' . $additionalWhere;
633
    }
634
635
    /**
636
     * This method can be used to retrieve all index queue configuration names, where
637
     * a certain table is used. It can be configured with the property "table" or is using the configuration
638
     * key a fallback for the table name.
639
     *
640
     * plugin.tx_solr.index.queue.<configurationName>.
641
     *
642
     * @param string $tableName
643
     * @param array $defaultIfEmpty
644
     * @return array
645
     */
646 10
    public function getIndexQueueConfigurationNamesByTableName($tableName, $defaultIfEmpty = [])
647
    {
648 10
        $path = 'plugin.tx_solr.index.queue.';
649 10
        $configuration = $this->getObjectByPathOrDefault($path, []);
650 10
        $possibleConfigurations = [];
651
652 10
        foreach ($configuration as $configurationName => $indexingEnabled) {
653 10
            $isObject = substr($configurationName, -1) == '.';
654 10
            if ($isObject || !$indexingEnabled) {
655 10
                continue;
656
            }
657
658
            // when the configuration name equals the tableName we have a fallback
659 10
            $hasTableNameAsConfigurationName = $configurationName == $tableName;
660 10
            $hasTableAssignedInQueueConfiguration = isset($configuration[$configurationName . '.']['table']) &&
661 10
                                                    $configuration[$configurationName . '.']['table'] == $tableName;
662 10
            if ($hasTableNameAsConfigurationName || $hasTableAssignedInQueueConfiguration) {
663 10
                $possibleConfigurations[] = $configurationName;
664
            }
665
        }
666
667 10
        return count($possibleConfigurations) > 0 ? $possibleConfigurations : $defaultIfEmpty;
668
    }
669
670
    /**
671
     * This method is used to retrieve the className of a queue initializer for a certain indexing configuration
672
     * of returns the default initializer class, when noting is configured.
673
     *
674
     * plugin.tx_solr.index.queue.<configurationName>.initialization
675
     *
676
     * @param string $configurationName
677
     * @param string $defaultIfEmpty
678
     * @return mixed
679
     */
680 5
    public function getIndexQueueInitializerClassByConfigurationName($configurationName, $defaultIfEmpty = Record::class)
681
    {
682 5
        $path = 'plugin.tx_solr.index.queue.' . $configurationName . '.initialization';
683 5
        $className = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty);
684
685 5
        return $className;
686
    }
687
688
    /**
689
     * Returns the configured javascript file for a specific fileKey.
690
     *
691
     * plugin.tx_solr.javascriptFiles.<fileKey>
692
     *
693
     * @param string $fileKey
694
     * @param string $defaultIfEmpty
695
     * @return string
696
     */
697 26
    public function getJavaScriptFileByFileKey($fileKey, $defaultIfEmpty = '')
698
    {
699 26
        $javaScriptFileName = $this->getValueByPathOrDefaultValue('plugin.tx_solr.javascriptFiles.' . $fileKey, $defaultIfEmpty);
700 26
        return (string)$javaScriptFileName;
701
    }
702
703
    /**
704
     * Returns the configuration where to load the javascript
705
     *
706
     * plugin.tx_solr.javascriptFiles.loadIn
707
     *
708
     * @param string $defaultIfEmpty
709
     * @return string
710
     */
711 25
    public function getJavaScriptLoadIn($defaultIfEmpty = 'footer')
712
    {
713 25
        $loadIn = $this->getValueByPathOrDefaultValue('plugin.tx_solr.javascriptFiles.loadIn', $defaultIfEmpty);
714 25
        return (string)$loadIn;
715
    }
716
717
    /**
718
     * Returns the _LOCAL_LANG configuration from the TypoScript.
719
     *
720
     * plugin.tx_solr._LOCAL_LANG.
721
     *
722
     * @param array $defaultIfEmpty
723
     * @return array
724
     */
725 25
    public function getLocalLangConfiguration(array $defaultIfEmpty = [])
726
    {
727 25
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr._LOCAL_LANG.', $defaultIfEmpty);
728 25
        return $result;
729
    }
730
731
    /**
732
     * When this is enabled the output of the devlog, will be printed as debug output.
733
     *
734
     * @param bool $defaultIfEmpty
735
     * @return bool
736
     */
737
    public function getLoggingDebugOutputDevlog($defaultIfEmpty = false)
738
    {
739
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.debugDevlogOutput', $defaultIfEmpty);
740
        return $this->getBool($result);
741
    }
742
743
    /**
744
     * Returns if query filters should be written to the log.
745
     *
746
     * plugin.tx_solr.logging.query.filters
747
     *
748
     * @param bool $defaultIfEmpty
749
     * @return bool
750
     */
751 36
    public function getLoggingQueryFilters($defaultIfEmpty = false)
752
    {
753 36
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.filters', $defaultIfEmpty);
754 36
        return $this->getBool($result);
755
    }
756
757
    /**
758
     * Returns if the querystring should be logged or not.
759
     *
760
     * plugin.tx_solr.logging.query.queryString
761
     *
762
     * @param bool $defaultIfEmpty
763
     * @return bool
764
     */
765 25
    public function getLoggingQueryQueryString($defaultIfEmpty = false)
766
    {
767 25
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.queryString', $defaultIfEmpty);
768 25
        return $this->getBool($result);
769
    }
770
771
    /**
772
     * Returns if the searchWords should be logged or not.
773
     *
774
     * plugin.tx_solr.logging.query.searchWords
775
     *
776
     * @param bool $defaultIfEmpty
777
     * @return bool
778
     */
779 24
    public function getLoggingQuerySearchWords($defaultIfEmpty = false)
780
    {
781 24
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.searchWords', $defaultIfEmpty);
782 24
        return $this->getBool($result);
783
    }
784
785
    /**
786
     * Returns if the rawGet requests should be logged or not.
787
     *
788
     * plugin.tx_solr.logging.query.rawGet
789
     *
790
     * @param bool $defaultIfEmpty
791
     * @return bool
792
     */
793 35
    public function getLoggingQueryRawGet($defaultIfEmpty = false)
794
    {
795 35
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.rawGet', $defaultIfEmpty);
796 35
        return $this->getBool($result);
797
    }
798
799
    /**
800
     * Returns if the rawPost requests should be logged or not.
801
     *
802
     * plugin.tx_solr.logging.query.rawPost
803
     *
804
     * @param bool $defaultIfEmpty
805
     * @return bool
806
     */
807 57
    public function getLoggingQueryRawPost($defaultIfEmpty = false)
808
    {
809 57
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.rawPost', $defaultIfEmpty);
810 57
        return $this->getBool($result);
811
    }
812
813
    /**
814
     * Returns if the rawDelete requests should be logged or not.
815
     *
816
     * plugin.tx_solr.logging.query.rawDelete
817
     *
818
     * @param bool $defaultIfEmpty
819
     * @return bool
820
     */
821 2
    public function getLoggingQueryRawDelete($defaultIfEmpty = false)
822
    {
823 2
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.query.rawDelete', $defaultIfEmpty);
824 2
        return $this->getBool($result);
825
    }
826
827
    /**
828
     * Returns if exceptions should be logged or not.
829
     *
830
     * plugin.tx_solr.logging.exceptions
831
     *
832
     * @param bool $defaultIfEmpty
833
     * @return bool
834
     */
835 1
    public function getLoggingExceptions($defaultIfEmpty = true)
836
    {
837 1
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.exceptions', $defaultIfEmpty);
838 1
        return $this->getBool($result);
839
    }
840
841
    /**
842
     * Returns if indexing operations should be logged or not.
843
     *
844
     * plugin.tx_solr.logging.indexing
845
     *
846
     * @param bool $defaultIfEmpty
847
     * @return bool
848
     */
849 54
    public function getLoggingIndexing($defaultIfEmpty = false)
850
    {
851 54
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing', $defaultIfEmpty);
852 54
        return $this->getBool($result);
853
    }
854
855
    /**
856
     * Returns if indexing queue operations should be logged or not.
857
     *
858
     * plugin.tx_solr.logging.indexing.queue
859
     *
860
     * @param bool $defaultIfEmpty
861
     * @return bool
862
     */
863 12
    public function getLoggingIndexingQueue($defaultIfEmpty = false)
864
    {
865 12
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing.queue', $defaultIfEmpty);
866 12
        return $this->getBool($result);
867
    }
868
869
    /**
870
     * This method can be used to check if the logging during indexing should be done.
871
     * It takes the specific configuration by indexQueueConfiguration into account or is using the
872
     * fallback when the logging is enabled on queue or indexing level.
873
     *
874
     * plugin.tx_solr.logging.indexing.queue.<indexQueueConfiguration>
875
     *
876
     * @param string $indexQueueConfiguration
877
     * @param bool $defaultIfEmpty
878
     * @return bool
879
     */
880 13
    public function getLoggingIndexingQueueOperationsByConfigurationNameWithFallBack($indexQueueConfiguration, $defaultIfEmpty = false)
881
    {
882
        // when logging is globally enabled we do not need to check the specific configuration
883 13
        if ($this->getLoggingIndexing()) {
884 1
            return true;
885
        }
886
887
        // when the logging for indexing is enabled on queue level we also do not need to check the specific configuration
888 12
        if ($this->getLoggingIndexingQueue()) {
889
            return true;
890
        }
891
892 12
        $path = 'plugin.tx_solr.logging.indexing.queue.' . $indexQueueConfiguration;
893 12
        $result = $this->getValueByPathOrDefaultValue($path, $defaultIfEmpty);
894 12
        return $this->getBool($result);
895
    }
896
897
    /**
898
     * Returns if a log message should be written when a page was indexed.
899
     *
900
     * plugin.tx_solr.logging.indexing.pageIndexed
901
902
     * @param bool $defaultIfEmpty
903
     * @return bool
904
     */
905 5
    public function getLoggingIndexingPageIndexed($defaultIfEmpty = false)
906
    {
907 5
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing.pageIndexed', $defaultIfEmpty);
908 5
        return $this->getBool($result);
909
    }
910
911
    /**
912
     * Returns if a log message should be written when the TYPO3 search markers are missing in the page.
913
     *
914
     * plugin.tx_solr.logging.indexing.missingTypo3SearchMarkers
915
916
     * @param bool $defaultIfEmpty
917
     * @return bool
918
     */
919 6
    public function getLoggingIndexingMissingTypo3SearchMarkers($defaultIfEmpty = true)
920
    {
921 6
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing.missingTypo3SearchMarkers', $defaultIfEmpty);
922 6
        return $this->getBool($result);
923
    }
924
925
    /**
926
     * Returns if the initialization of an indexqueue should be logged.
927
     *
928
     * plugin.tx_solr.logging.indexing.indexQueueInitialization
929
     *
930
     * @param bool $defaultIfEmpty
931
     * @return bool
932
     */
933 7
    public function getLoggingIndexingIndexQueueInitialization($defaultIfEmpty = false)
934
    {
935 7
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.logging.indexing.indexQueueInitialization', $defaultIfEmpty);
936 7
        return $this->getBool($result);
937
    }
938
939
    /**
940
     * Indicates if the debug mode is enabled or not.
941
     *
942
     * plugin.tx_solr.enableDebugMode
943
944
     * @param bool $defaultIfEmpty
945
     * @return bool
946
     */
947 24
    public function getEnabledDebugMode($defaultIfEmpty = false)
948
    {
949 24
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.enableDebugMode', $defaultIfEmpty);
950 24
        return $this->getBool($result);
951
    }
952
953
    /**
954
     * Returns true or false if something is configured below plugin.tx_solr.solr.
955
     *
956
     * plugin.tx_solr.solr.
957
     *
958
     * @param boolean $defaultIfEmpty
959
     * @return boolean
960
     */
961 3
    public function getSolrHasConnectionConfiguration($defaultIfEmpty = false)
962
    {
963 3
        $configuration = $this->getObjectByPathOrDefault('plugin.tx_solr.solr.', []);
964 3
        return $configuration !== [] ? true : $defaultIfEmpty;
965
    }
966
967
    /**
968
     * Returns the defaultTimeout used for requests to the Solr server
969
     *
970
     * plugin.tx_solr.solr.timeout
971
     *
972
     * @param float $defaultIfEmpty
973
     * @return float
974
     */
975 74
    public function getSolrTimeout($defaultIfEmpty = 0.0)
976
    {
977 74
        return (float)$this->getValueByPathOrDefaultValue('plugin.tx_solr.solr.timeout', $defaultIfEmpty);
978
    }
979
980
    /**
981
     * Returns the scheme used for requests to the Solr server
982
     *
983
     * plugin.tx_solr.solr.scheme
984
     *
985
     * Applies stdWrap on the configured setting
986
     *
987
     * @param string $defaultIfEmpty
988
     * @return string
989
     */
990 4
    public function getSolrScheme($defaultIfEmpty = 'http')
991
    {
992 4
        $valuePath = 'plugin.tx_solr.solr.scheme';
993 4
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
994 4
        return $this->renderContentElementOfConfigured($valuePath, $value);
995
    }
996
997
    /**
998
     * Returns the hostname used for requests to the Solr server
999
     *
1000
     * plugin.tx_solr.solr.host
1001
     *
1002
     * Applies stdWrap on the configured setting
1003
     *
1004
     * @param string $defaultIfEmpty
1005
     * @return string
1006
     */
1007 7
    public function getSolrHost($defaultIfEmpty = 'localhost')
1008
    {
1009 7
        $valuePath = 'plugin.tx_solr.solr.host';
1010 7
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
1011 7
        return $this->renderContentElementOfConfigured($valuePath, $value);
1012
    }
1013
1014
    /**
1015
     * Returns the port used for requests to the Solr server
1016
     *
1017
     * plugin.tx_solr.solr.port
1018
     *
1019
     * Applies stdWrap on the configured setting
1020
     *
1021
     * @param int $defaultIfEmpty
1022
     * @return int
1023
     */
1024 4
    public function getSolrPort($defaultIfEmpty = 8983)
1025
    {
1026 4
        $valuePath = 'plugin.tx_solr.solr.port';
1027 4
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
1028 4
        return $this->renderContentElementOfConfigured($valuePath, $value);
1029
    }
1030
1031
    /**
1032
     * Returns the path used for requests to the Solr server
1033
     *
1034
     * plugin.tx_solr.solr.path
1035
     *
1036
     * Applies stdWrap on the configured setting
1037
     *
1038
     * @param string $defaultIfEmpty
1039
     * @return string
1040
     */
1041 7
    public function getSolrPath($defaultIfEmpty = '/solr/core_en/')
1042
    {
1043 7
        $valuePath = 'plugin.tx_solr.solr.path';
1044 7
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
1045 7
        $solrPath = $this->renderContentElementOfConfigured($valuePath, $value);
1046
1047 7
        $solrPath = trim($solrPath, '/');
1048 7
        $solrPath = '/' . $solrPath . '/';
1049
1050 7
        return $solrPath;
1051
    }
1052
1053
    /**
1054
     * Returns the username used for requests to the Solr server
1055
     *
1056
     * plugin.tx_solr.solr.username
1057
     *
1058
     * Applies stdWrap on the configured setting
1059
     *
1060
     * @param string $defaultIfEmpty
1061
     * @return string
1062
     */
1063 4
    public function getSolrUsername($defaultIfEmpty = '')
1064
    {
1065 4
        $valuePath = 'plugin.tx_solr.solr.username';
1066 4
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
1067 4
        return $this->renderContentElementOfConfigured($valuePath, $value);
1068
    }
1069
1070
    /**
1071
     * Returns the password used for requests to the Solr server
1072
     *
1073
     * plugin.tx_solr.solr.password
1074
     *
1075
     * Applies stdWrap on the configured setting
1076
     *
1077
     * @param string $defaultIfEmpty
1078
     * @return string
1079
     */
1080 4
    public function getSolrPassword($defaultIfEmpty = '')
1081
    {
1082 4
        $valuePath = 'plugin.tx_solr.solr.password';
1083 4
        $value = (string)$this->getValueByPathOrDefaultValue($valuePath, $defaultIfEmpty);
1084 4
        return $this->renderContentElementOfConfigured($valuePath, $value);
1085
    }
1086
1087
    /**
1088
     * Retrieves the complete search configuration
1089
     *
1090
     * plugin.tx_solr.search.
1091
     *
1092
     * @param array $defaultIfEmpty
1093
     * @return array
1094
     */
1095 24
    public function getSearchConfiguration(array $defaultIfEmpty = [])
1096
    {
1097 24
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.', $defaultIfEmpty);
1098 24
        return $result;
1099
    }
1100
1101
    /**
1102
     * Indicates if elevation should be used or not
1103
     *
1104
     * plugin.tx_solr.search.elevation
1105
     *
1106
     * @param bool $defaultIfEmpty
1107
     * @return bool
1108
     */
1109 24
    public function getSearchElevation($defaultIfEmpty = false)
1110
    {
1111 24
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.elevation', $defaultIfEmpty);
1112 24
        return $this->getBool($result);
1113
    }
1114
1115
    /**
1116
     * Indicates if elevated results should be marked
1117
     *
1118
     * plugin.tx_solr.search.elevation.markElevatedResults
1119
     *
1120
     * @param bool $defaultIfEmpty
1121
     * @return bool
1122
     */
1123 24
    public function getSearchElevationMarkElevatedResults($defaultIfEmpty = true)
1124
    {
1125 24
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.elevation.markElevatedResults', $defaultIfEmpty);
1126 24
        return $this->getBool($result);
1127
    }
1128
1129
    /**
1130
     * Indicates if elevation should be forced
1131
     *
1132
     *plugin.tx_solr.search.elevation.forceElevation
1133
     *
1134
     * @param bool $defaultIfEmpty
1135
     * @return bool
1136
     */
1137 24
    public function getSearchElevationForceElevation($defaultIfEmpty = true)
1138
    {
1139 24
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.elevation.forceElevation', $defaultIfEmpty);
1140 24
        return $this->getBool($result);
1141
    }
1142
1143
    /**
1144
     * Indicates if collapsing on a certain field should be used to build variants or not.
1145
     *
1146
     * plugin.tx_solr.search.variants
1147
     *
1148
     * @param bool $defaultIfEmpty
1149
     * @return bool
1150
     */
1151 128
    public function getSearchVariants($defaultIfEmpty = false)
1152
    {
1153 128
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.variants', $defaultIfEmpty);
1154 128
        return $this->getBool($result);
1155
    }
1156
1157
    /**
1158
     * Indicates if collapsing on a certain field should be used or not
1159
     *
1160
     * plugin.tx_solr.search.variants.variantField
1161
     *
1162
     * @param string $defaultIfEmpty
1163
     * @return string
1164
     */
1165 3
    public function getSearchVariantsField($defaultIfEmpty = 'variantId')
1166
    {
1167 3
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.variants.variantField', $defaultIfEmpty);
1168
    }
1169
1170
    /**
1171
     * Indicates if expanding of collapsed items it activated.
1172
     *
1173
     * plugin.tx_solr.search.variants.expand
1174
     *
1175
     * @param bool $defaultIfEmpty
1176
     * @return bool
1177
     */
1178 4
    public function getSearchVariantsExpand($defaultIfEmpty = false)
1179
    {
1180 4
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.variants.expand', $defaultIfEmpty);
1181 4
        return $this->getBool($result);
1182
    }
1183
1184
    /**
1185
     * Retrieves the number of elements that should be expanded.
1186
     *
1187
     * plugin.tx_solr.search.variants.limit
1188
     *
1189
     * @param int $defaultIfEmpty
1190
     * @return int
1191
     */
1192 2
    public function getSearchVariantsLimit($defaultIfEmpty = 10)
1193
    {
1194 2
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.variants.limit', $defaultIfEmpty);
1195 2
        return (int)$result;
1196
    }
1197
1198
    /**
1199
     * Indicates if frequent searches should be show or not.
1200
     *
1201
     * plugin.tx_solr.search.frequentSearches
1202
     *
1203
     * @param bool $defaultIfEmpty
1204
     * @return bool
1205
     */
1206 23
    public function getSearchFrequentSearches($defaultIfEmpty = false)
1207
    {
1208 23
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches', $defaultIfEmpty);
1209 23
        return $this->getBool($result);
1210
    }
1211
1212
    /**
1213
     * Returns the sub configuration of the frequentSearches
1214
     *
1215
     * plugin.tx_solr.search.frequentSearches.
1216
     *
1217
     * @param array $defaultIfEmpty
1218
     * @return array
1219
     */
1220 23
    public function getSearchFrequentSearchesConfiguration($defaultIfEmpty = [])
1221
    {
1222 23
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.frequentSearches.', $defaultIfEmpty);
1223 23
        return $result;
1224
    }
1225
1226
    /**
1227
     * Retrieves the minimum font size that should be used for the frequentSearches.
1228
     *
1229
     * plugin.tx_solr.search.frequentSearches.minSize
1230
     *
1231
     * @param int $defaultIfEmpty
1232
     * @return int
1233
     */
1234
    public function getSearchFrequentSearchesMinSize($defaultIfEmpty = 14)
1235
    {
1236
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches.minSize', $defaultIfEmpty);
1237
        return (int)$result;
1238
    }
1239
1240
    /**
1241
     * Retrieves the maximum font size that should be used for the frequentSearches.
1242
     *
1243
     * plugin.tx_solr.search.frequentSearches.minSize
1244
     *
1245
     * @param int $defaultIfEmpty
1246
     * @return int
1247
     */
1248
    public function getSearchFrequentSearchesMaxSize($defaultIfEmpty = 32)
1249
    {
1250
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches.maxSize', $defaultIfEmpty);
1251
        return (int)$result;
1252
    }
1253
1254
    /**
1255
     * Indicates if frequent searches should be show or not.
1256
     *
1257
     * plugin.tx_solr.search.frequentSearches.useLowercaseKeywords
1258
     *
1259
     * @param bool $defaultIfEmpty
1260
     * @return bool
1261
     */
1262 18
    public function getSearchFrequentSearchesUseLowercaseKeywords($defaultIfEmpty = false)
1263
    {
1264 18
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches.useLowercaseKeywords', $defaultIfEmpty);
1265 18
        return $this->getBool($result);
1266
    }
1267
1268
    /**
1269
     * Returns the configuration if the search should be initialized with an empty query.
1270
     *
1271
     * plugin.tx_solr.search.initializeWithEmptyQuery
1272
     *
1273
     * @param bool $defaultIfEmpty
1274
     * @return bool
1275
     */
1276 26
    public function getSearchInitializeWithEmptyQuery($defaultIfEmpty = false)
1277
    {
1278 26
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.initializeWithEmptyQuery', $defaultIfEmpty);
1279 26
        return $this->getBool($result);
1280
    }
1281
1282
    /**
1283
     * Returns the configured initial query
1284
     *
1285
     * plugin.tx_solr.search.initializeWithQuery
1286
     *
1287
     * @param string $defaultIfEmpty
1288
     * @return string
1289
     */
1290 26
    public function getSearchInitializeWithQuery($defaultIfEmpty = '')
1291
    {
1292 26
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.initializeWithQuery', $defaultIfEmpty);
1293 26
        return (string)$result;
1294
    }
1295
1296
    /**
1297
     * Returns if the last searches should be displayed or not.
1298
     *
1299
     * plugin.tx_solr.search.lastSearches
1300
     *
1301
     * @param bool $defaultIfEmpty
1302
     * @return bool
1303
     */
1304 23
    public function getSearchLastSearches($defaultIfEmpty = false)
1305
    {
1306 23
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.lastSearches', $defaultIfEmpty);
1307 23
        return $this->getBool($result);
1308
    }
1309
1310
    /**
1311
     * Returns the lastSearch mode. "user" for user specific
1312
     *
1313
     * plugin.tx_solr.search.lastSearches.mode
1314
     *
1315
     * @param string $defaultIfEmpty
1316
     * @return string
1317
     */
1318 23
    public function getSearchLastSearchesMode($defaultIfEmpty = 'user')
1319
    {
1320 23
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.lastSearches.mode', $defaultIfEmpty);
1321 23
        return (string)$result;
1322
    }
1323
1324
    /**
1325
     * Returns the lastSearch limit
1326
     *
1327
     * plugin.tx_solr.search.lastSearches.limit
1328
     *
1329
     * @param int $defaultIfEmpty
1330
     * @return int
1331
     */
1332 23
    public function getSearchLastSearchesLimit($defaultIfEmpty = 10)
1333
    {
1334 23
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.lastSearches.limit', $defaultIfEmpty);
1335 23
        return (int)$result;
1336
    }
1337
1338
    /**
1339
     * Returns the search results fieldProcessingInstructions configuration array
1340
     *
1341
     * plugin.tx_solr.search.results.fieldProcessingInstructions.
1342
     *
1343
     * @param array $defaultIfEmpty
1344
     * @return array
1345
     */
1346 18
    public function getSearchResultsFieldProcessingInstructionsConfiguration(array $defaultIfEmpty = [])
1347
    {
1348 18
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.results.fieldProcessingInstructions.', $defaultIfEmpty);
1349 18
        return $result;
1350
    }
1351
1352
    /**
1353
     * Returns the search results fieldRenderingInstructions configuration array
1354
     *
1355
     * plugin.tx_solr.search.results.fieldRenderingInstructions.
1356
     *
1357
     * @param array $defaultIfEmpty
1358
     * @return array
1359
     */
1360 18
    public function getSearchResultsFieldRenderingInstructionsConfiguration(array $defaultIfEmpty = [])
1361
    {
1362 18
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.results.fieldRenderingInstructions.', $defaultIfEmpty);
1363 18
        return $result;
1364
    }
1365
1366
    /**
1367
     * Indicates if the results of an initial empty query should be shown or not.
1368
     *
1369
     * plugin.tx_solr.search.showResultsOfInitialEmptyQuery
1370
     *
1371
     * @param bool $defaultIfEmpty
1372
     * @return bool
1373
     */
1374 4
    public function getSearchShowResultsOfInitialEmptyQuery($defaultIfEmpty = false)
1375
    {
1376 4
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.showResultsOfInitialEmptyQuery', $defaultIfEmpty);
1377 4
        return $this->getBool($result);
1378
    }
1379
1380
    /**
1381
     * Indicates if the results of an initial search query should be shown.
1382
     *
1383
     * plugin.tx_solr.search.showResultsOfInitialQuery
1384
     *
1385
     * @param bool $defaultIfEmpty
1386
     * @return bool
1387
     */
1388 4
    public function getSearchShowResultsOfInitialQuery($defaultIfEmpty = false)
1389
    {
1390 4
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.showResultsOfInitialQuery', $defaultIfEmpty);
1391 4
        return $this->getBool($result);
1392
    }
1393
1394
    /**
1395
     * Indicates if sorting was enabled or not.
1396
     *
1397
     * plugin.tx_solr.search.sorting
1398
     *
1399
     * @param bool $defaultIfEmpty
1400
     * @return bool
1401
     */
1402 17
    public function getSearchSorting($defaultIfEmpty = false)
1403
    {
1404 17
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.sorting', $defaultIfEmpty);
1405 17
        return $this->getBool($result);
1406
    }
1407
1408
    /**
1409
     * Returns the sorting options configurations.
1410
     *
1411
     * plugin.tx_solr.search.sorting.options.
1412
     *
1413
     * @param array $defaultIfEmpty
1414
     * @return array
1415
     */
1416 17
    public function getSearchSortingOptionsConfiguration($defaultIfEmpty = [])
1417
    {
1418 17
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.sorting.options.', $defaultIfEmpty);
1419 17
        return $result;
1420
    }
1421
1422
    /**
1423
     * Retrieves the sorting default order for a sort option.
1424
     *
1425
     * plugin.tx_solr.search.sorting.options.<sortOptionName>.defaultOrder
1426
     *
1427
     * or
1428
     *
1429
     * plugin.tx_solr.search.sorting.defaultOrder
1430
     *
1431
     *
1432
     * @param string $sortOptionName
1433
     * @param string $defaultIfEmpty
1434
     * @return string
1435
     */
1436 17
    public function getSearchSortingDefaultOrderBySortOptionName($sortOptionName = '', $defaultIfEmpty = 'asc')
1437
    {
1438 17
        $sortOrderSpecificPath = 'plugin.tx_solr.search.sorting.options.' . $sortOptionName . '.defaultOrder';
1439 17
        $specificSortOrder = $this->getValueByPathOrDefaultValue($sortOrderSpecificPath, null);
1440
1441
        // if we have a concrete setting, use it
1442 17
        if ($specificSortOrder !== null) {
1443
            return $specificSortOrder;
1444
        }
1445
1446
        // no specific setting, check common setting
1447 17
        $commonPath = 'plugin.tx_solr.search.sorting.defaultOrder';
1448 17
        $commonATagParamOrDefaultValue = $this->getValueByPathOrDefaultValue($commonPath, $defaultIfEmpty);
1449 17
        return $commonATagParamOrDefaultValue;
1450
    }
1451
1452
    /**
1453
     * Returns the configured fixedOrder, if nothing configured defaultIfEmpty will be returned.
1454
     *
1455
     * plugin.tx_solr.search.sorting.options.<sortOptionName>.fixedOrder
1456
     *
1457
     * @param string $sortOptionName
1458
     * @param string $defaultIfEmpty
1459
     * @return string
1460
     */
1461 17
    public function getSearchSortingFixedOrderBySortOptionName($sortOptionName = '', $defaultIfEmpty = '')
1462
    {
1463 17
        $fixedOrder = 'plugin.tx_solr.search.sorting.options.' . $sortOptionName . '.fixedOrder';
1464 17
        return $this->getValueByPathOrDefaultValue($fixedOrder, $defaultIfEmpty);
1465
    }
1466
1467
    /**
1468
     * Returns the trusted fields configured for the search that do not need to be escaped.
1469
     *
1470
     * @param array $defaultIfEmpty
1471
     * @return array
1472
     */
1473 18
    public function getSearchTrustedFieldsArray($defaultIfEmpty = ['url'])
1474
    {
1475 18
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.trustedFields', '');
1476
1477 18
        if (trim($result) === '') {
1478
            return $defaultIfEmpty;
1479
        }
1480
1481 18
        return GeneralUtility::trimExplode(',', $result);
1482
    }
1483
1484
    /**
1485
     * Indicates if the plugin arguments should be kept in the search form for a second submission.
1486
     *
1487
     * plugin.tx_solr.search.keepExistingParametersForNewSearches
1488
     *
1489
     * @param bool $defaultIfEmpty
1490
     * @return bool
1491
     */
1492 23
    public function getSearchKeepExistingParametersForNewSearches($defaultIfEmpty = false)
1493
    {
1494 23
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.keepExistingParametersForNewSearches', $defaultIfEmpty);
1495 23
        return $this->getBool($result);
1496
    }
1497
1498
    /**
1499
     * Returns if an empty query is allowed on the query level.
1500
     *
1501
     * plugin.tx_solr.search.query.allowEmptyQuery
1502
     *
1503
     * @param string $defaultIfEmpty
1504
     * @return string
1505
     */
1506 26
    public function getSearchQueryAllowEmptyQuery($defaultIfEmpty = '')
1507
    {
1508 26
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.allowEmptyQuery', $defaultIfEmpty);
1509 26
        return $this->getBool($result);
1510
    }
1511
1512
    /**
1513
     * Returns the fieldProcessingInstructions configuration array
1514
     *
1515
     * plugin.tx_solr.search.query.filter.
1516
     *
1517
     * @param array $defaultIfEmpty
1518
     * @return array
1519
     */
1520 32
    public function getSearchQueryFilterConfiguration(array $defaultIfEmpty = [])
1521
    {
1522 32
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.query.filter.', $defaultIfEmpty);
1523 32
        return $result;
1524
    }
1525
1526
    /**
1527
     * Can be used to overwrite the filterConfiguration.
1528
     *
1529
     * plugin.tx_solr.search.query.filter.
1530
     *
1531
     * @param array $configuration
1532
     */
1533 1
    public function setSearchQueryFilterConfiguration(array $configuration)
1534
    {
1535 1
        $this->configurationAccess->set('plugin.tx_solr.search.query.filter.', $configuration);
1536 1
    }
1537
1538
    /**
1539
     * Removes the pageSections filter setting.
1540
     *
1541
     * @return void
1542
     */
1543 2
    public function removeSearchQueryFilterForPageSections()
1544
    {
1545 2
        $this->configurationAccess->reset('plugin.tx_solr.search.query.filter.__pageSections');
1546 2
    }
1547
1548
    /**
1549
     * Returns the configured queryFields from TypoScript
1550
     *
1551
     * plugin.tx_solr.search.query.queryFields
1552
     *
1553
     * @param string $defaultIfEmpty
1554
     * @return string
1555
     */
1556 129
    public function getSearchQueryQueryFields($defaultIfEmpty = '')
1557
    {
1558 129
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.query.queryFields', $defaultIfEmpty);
1559
    }
1560
1561
    /**
1562
     * Returns the configured returnFields as array.
1563
     *
1564
     * plugin.tx_solr.search.query.returnFields
1565
     *
1566
     * @param array $defaultIfEmpty
1567
     * @return array
1568
     */
1569 129
    public function getSearchQueryReturnFieldsAsArray($defaultIfEmpty = [])
1570
    {
1571 129
        $returnFields = $this->getValueByPath('plugin.tx_solr.search.query.returnFields');
1572 129
        if (is_null($returnFields)) {
1573 103
            return $defaultIfEmpty;
1574
        }
1575 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...
1576
    }
1577
1578
    /**
1579
     * Returns the configured target page for the search.
1580
     * By default the contextPageId will be used
1581
     *
1582
     * plugin.tx_solr.search.targetPage
1583
     *
1584
     * @return int
1585
     */
1586 134
    public function getSearchTargetPage()
1587
    {
1588 134
        $targetPage = (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.targetPage', 0);
1589 134
        if ($targetPage === 0) {
1590
            // when no specific page was configured we use the contextPageId (which is usual $GLOBALS['TSFE']->id)
1591 83
            $targetPage = $this->contextPageId;
1592
        }
1593
1594 134
        return $targetPage;
1595
    }
1596
1597
    /**
1598
     * Retrieves the targetPage configuration.
1599
     *
1600
     * plugin.tx_solr.search.targetPage.
1601
     *
1602
     * @param array $defaultIfEmpty
1603
     * @return array
1604
     */
1605 28
    public function getSearchTargetPageConfiguration(array $defaultIfEmpty = [])
1606
    {
1607 28
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.targetPage.', $defaultIfEmpty);
1608 28
        return $result;
1609
    }
1610
1611
    /**
1612
     * Retrieves the pagebrowser configuration.
1613
     *
1614
     * plugin.tx_solr.search.results.pagebrowser.
1615
     *
1616
     * @param array $defaultIfEmpty
1617
     * @return array
1618
     */
1619 18
    public function getSearchResultsPageBrowserConfiguration(array $defaultIfEmpty = [])
1620
    {
1621 18
        $result = $this->getObjectByPathOrDefault('plugin.tx_solr.search.results.pagebrowser.', $defaultIfEmpty);
1622 18
        return $result;
1623
    }
1624
1625
    /**
1626
     * Returns the result highlighting fields.
1627
     *
1628
     * plugin.tx_solr.search.results.resultsHighlighting.highlightFields
1629
     *
1630
     * @param string $defaultIfEmpty
1631
     * @return string
1632
     */
1633 31
    public function getSearchResultsHighlightingFields($defaultIfEmpty = '')
1634
    {
1635 31
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsHighlighting.highlightFields', $defaultIfEmpty);
1636
    }
1637
1638
    /**
1639
     * Returns the result highlighting fields as array.
1640
     *
1641
     * plugin.tx_solr.search.results.resultsHighlighting.highlightFields
1642
     *
1643
     * @param array $defaultIfEmpty
1644
     * @return array
1645
     */
1646 18
    public function getSearchResultsHighlightingFieldsAsArray($defaultIfEmpty = [])
1647
    {
1648 18
        $highlightingFields = $this->getSearchResultsHighlightingFields('');
1649
1650 18
        if ($highlightingFields === '') {
1651
            return $defaultIfEmpty;
1652
        }
1653
1654 18
        return GeneralUtility::trimExplode(',', $highlightingFields, true);
1655
    }
1656
1657
    /**
1658
     * Returns the fragmentSeparator for highlighted segments.
1659
     *
1660
     * plugin.tx_solr.search.results.resultsHighlighting.fragmentSeparator
1661
     *
1662
     * @param string $defaultIfEmpty
1663
     * @return string
1664
     */
1665 18
    public function getSearchResultsHighlightingFragmentSeparator($defaultIfEmpty = '[...]')
1666
    {
1667 18
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsHighlighting.fragmentSeparator', $defaultIfEmpty);
1668
    }
1669
1670
    /**
1671
     * Returns the number of results that should be shown per page.
1672
     *
1673
     * plugin.tx_solr.search.results.resultsPerPage
1674
     *
1675
     * @param int $defaultIfEmpty
1676
     * @return int
1677
     */
1678 24
    public function getSearchResultsPerPage($defaultIfEmpty = 10)
1679
    {
1680 24
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsPerPage', $defaultIfEmpty);
1681
    }
1682
1683
    /**
1684
     * Returns the available options for the per page switch.
1685
     *
1686
     * plugin.tx_solr.search.results.resultsPerPageSwitchOptions
1687
     *
1688
     * @param array $defaultIfEmpty
1689
     * @return array
1690
     */
1691 24
    public function getSearchResultsPerPageSwitchOptionsAsArray($defaultIfEmpty = [])
1692
    {
1693 24
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsPerPageSwitchOptions', '');
1694
1695 24
        if (trim($result) === '') {
1696
            return $defaultIfEmpty;
1697
        }
1698
1699 24
        return GeneralUtility::intExplode(',', $result, true);
1700
    }
1701
1702
    /**
1703
     * Returns the configured wrap for the resultHighlighting.
1704
     *
1705
     * plugin.tx_solr.search.results.resultsHighlighting.wrap
1706
     *
1707
     * @param string $defaultIfEmpty
1708
     * @return string
1709
     */
1710 31
    public function getSearchResultsHighlightingWrap($defaultIfEmpty = '')
1711
    {
1712 31
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.results.resultsHighlighting.wrap', $defaultIfEmpty);
1713
    }
1714
1715
    /**
1716
     * Indicates if spellchecking is enabled or not.
1717
     *
1718
     * plugin.tx_solr.search.spellchecking
1719
     *
1720
     * @param bool $defaultIfEmpty
1721
     * @return bool
1722
     */
1723 25
    public function getSearchSpellchecking($defaultIfEmpty = false)
1724
    {
1725 25
        $isFacetingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking', $defaultIfEmpty);
1726 25
        return $this->getBool($isFacetingEnabled);
1727
    }
1728
1729
    /**
1730
     * Returns the wrap that should be used for spellchecking
1731
     *
1732
     * plugin.tx_solr.search.spellchecking.wrap
1733
     *
1734
     * @param string $defaultIfEmpty
1735
     * @return string
1736
     */
1737 5
    public function getSearchSpellcheckingWrap($defaultIfEmpty = '')
1738
    {
1739 5
        return (string)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking.wrap', $defaultIfEmpty);
1740
    }
1741
1742
    /**
1743
     * Returns the numberOfSuggestionsToTry that should be used for the spellchecking.
1744
     *
1745
     * plugin.tx_solr.search.spellchecking.numberOfSuggestionsToTry
1746
     *
1747
     * @param int $defaultIfEmpty
1748
     * @return int
1749
     */
1750 22
    public function getSearchSpellcheckingNumberOfSuggestionsToTry($defaultIfEmpty = 0)
1751
    {
1752 22
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking.numberOfSuggestionsToTry', $defaultIfEmpty);
1753
    }
1754
1755
    /**
1756
     * Indicates if a second search should be fired from the spellchecking suggestion if no results could be found.
1757
     *
1758
     * plugin.tx_solr.search.spellchecking.searchUsingSpellCheckerSuggestion
1759
     *
1760
     * @param bool $defaultIfEmpty
1761
     * @return bool
1762
     */
1763 3
    public function getSearchSpellcheckingSearchUsingSpellCheckerSuggestion($defaultIfEmpty = false)
1764
    {
1765 3
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.spellchecking.searchUsingSpellCheckerSuggestion', $defaultIfEmpty);
1766 3
        return $this->getBool($result);
1767
    }
1768
1769
    /**
1770
     * Indicates if faceting is enabled or not.
1771
     *
1772
     * plugin.tx_solr.search.faceting
1773
     *
1774
     * @param bool $defaultIfEmpty
1775
     * @return bool
1776
     */
1777 20
    public function getSearchFaceting($defaultIfEmpty = false)
1778
    {
1779 20
        $isFacetingEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting', $defaultIfEmpty);
1780 20
        return $this->getBool($isFacetingEnabled);
1781
    }
1782
1783
    /**
1784
     * Retrieves the facetLinkATagParams for a facet by facet name. If nothing specific is configured
1785
     * the global facetLinkATagParams with be returned.
1786
     *
1787
     * plugin.tx_solr.search.faceting.facets.<facetName>.facetLinkATagParams
1788
     *
1789
     * or
1790
     *
1791
     * plugin.tx_solr.search.faceting.facetLinkATagParams
1792
     *
1793
     *
1794
     * @param string $facetName
1795
     * @param string $defaultIfEmpty
1796
     * @return string
1797
     */
1798 19
    public function getSearchFacetingFacetLinkATagParamsByName($facetName = '', $defaultIfEmpty = '')
1799
    {
1800 19
        $facetSpecificPath = 'plugin.tx_solr.search.faceting.facets.' . $facetName . '.facetLinkATagParams';
1801 19
        $specificATagParam = $this->getValueByPathOrDefaultValue($facetSpecificPath, null);
1802
1803
            // if we have a concrete setting, use it
1804 19
        if ($specificATagParam !== null) {
1805 1
            return $specificATagParam;
1806
        }
1807
1808
            // no specific setting, check common setting
1809 19
        $commonPath = 'plugin.tx_solr.search.faceting.facetLinkATagParams';
1810 19
        $commonATagParamOrDefaultValue = $this->getValueByPathOrDefaultValue($commonPath, $defaultIfEmpty);
1811 19
        return $commonATagParamOrDefaultValue;
1812
    }
1813
1814
    /**
1815
     * Returns the test that should be used to remove a faceting link
1816
     *
1817
     * plugin.tx_solr.search.faceting.removeFacetLinkText
1818
     *
1819
     * @param string $defaultIfEmpty
1820
     * @return string
1821
     */
1822 1
    public function getSearchFacetingRemoveFacetLinkText($defaultIfEmpty = '@facetLabel: @facetText')
1823
    {
1824 1
        return (string)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.removeFacetLinkText', $defaultIfEmpty);
1825
    }
1826
1827
    /**
1828
     * Retrieves the showEvenWhenEmpty for a facet by facet name. If nothing specific is configured
1829
     * the global showEmptyFacets with be returned.
1830
     *
1831
     * plugin.tx_solr.search.faceting.facets.<facetName>.showEvenWhenEmpty
1832
     *
1833
     * or
1834
     *
1835
     * plugin.tx_solr.search.faceting.showEmptyFacets
1836
     *
1837
     *
1838
     * @param string $facetName
1839
     * @param bool $defaultIfEmpty
1840
     * @return bool
1841
     */
1842 19
    public function getSearchFacetingShowEmptyFacetsByName($facetName = '', $defaultIfEmpty = false)
1843
    {
1844 19
        $facetSpecificPath = 'plugin.tx_solr.search.faceting.facets.' . $facetName . '.showEvenWhenEmpty';
1845 19
        $specificShowWhenEmpty = $this->getValueByPathOrDefaultValue($facetSpecificPath, null);
1846
1847
        // if we have a concrete setting, use it
1848 19
        if ($specificShowWhenEmpty !== null) {
1849 1
            return $specificShowWhenEmpty;
1850
        }
1851
1852
        // no specific setting, check common setting
1853 19
        $commonPath = 'plugin.tx_solr.search.faceting.showEmptyFacets';
1854 19
        $commonIfEmptyOrDefaultValue = $this->getValueByPathOrDefaultValue($commonPath, $defaultIfEmpty);
1855 19
        return $commonIfEmptyOrDefaultValue;
1856
    }
1857
1858
    /**
1859
     * Returns the wrap for the faceting show all link
1860
     *
1861
     * plugin.tx_solr.search.faceting.showAllLink.wrap
1862
     *
1863
     * @param string $defaultIfEmpty
1864
     * @return string
1865
     */
1866
    public function getSearchFacetingShowAllLinkWrap($defaultIfEmpty = '')
1867
    {
1868
        return (string)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.showAllLink.wrap', $defaultIfEmpty);
1869
    }
1870
1871
    /**
1872
     * Returns the link url parameters that should be added to a facet.
1873
     *
1874
     * plugin.tx_solr.search.faceting.facetLinkUrlParameters
1875
     *
1876
     * @param string $defaultIfEmpty
1877
     * @return string
1878
     */
1879 18
    public function getSearchFacetingFacetLinkUrlParameters($defaultIfEmpty = '')
1880
    {
1881 18
        $linkUrlParameters = trim($this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.facetLinkUrlParameters', $defaultIfEmpty));
1882
1883 18
        return $linkUrlParameters;
1884
    }
1885
1886
    /**
1887
     * Returns if the facetLinkUrlsParameters should be included in the reset link.
1888
     *
1889
     * plugin.tx_solr.search.faceting.facetLinkUrlParameters.useForFacetResetLinkUrl
1890
     *
1891
     * @param bool $defaultIfEmpty
1892
     * @return bool
1893
     */
1894 18
    public function getSearchFacetingFacetLinkUrlParametersUseForFacetResetLinkUrl($defaultIfEmpty = true)
1895
    {
1896 18
        $useForFacetResetLinkUrl = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.facetLinkUrlParameters.useForFacetResetLinkUrl', $defaultIfEmpty);
1897 18
        return $this->getBool($useForFacetResetLinkUrl);
1898
    }
1899
1900
    /**
1901
     * Returns the link url parameters that should be added to a facet as array.
1902
     *
1903
     * plugin.tx_solr.search.faceting.facetLinkUrlParameters
1904
     *
1905
     * @param array $defaultIfEmpty
1906
     * @return array
1907
     */
1908 18
    public function getSearchFacetingFacetLinkUrlParametersAsArray($defaultIfEmpty = [])
1909
    {
1910 18
        $linkUrlParameters = $this->getSearchFacetingFacetLinkUrlParameters();
1911 18
        if ($linkUrlParameters === '') {
1912
            return $defaultIfEmpty;
1913
        }
1914
1915 18
        return GeneralUtility::explodeUrl2Array($linkUrlParameters);
1916
    }
1917
1918
    /**
1919
     * Return the configured minimumCount value for facets.
1920
     *
1921
     * plugin.tx_solr.search.faceting.minimumCount
1922
     *
1923
     * @param int $defaultIfEmpty
1924
     * @return int
1925
     */
1926 31
    public function getSearchFacetingMinimumCount($defaultIfEmpty = 1)
1927
    {
1928 31
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.minimumCount', $defaultIfEmpty);
1929
    }
1930
1931
    /**
1932
     * Return the configured limit value for facets, used for displaying.
1933
     *
1934
     * plugin.tx_solr.search.faceting.limit
1935
     *
1936
     * @param int $defaultIfEmpty
1937
     * @return int
1938
     */
1939 18
    public function getSearchFacetingLimit($defaultIfEmpty = 10)
1940
    {
1941 18
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.limit', $defaultIfEmpty);
1942
    }
1943
1944
    /**
1945
     * Return the configured limit value for facets, used for the response.
1946
     *
1947
     * plugin.tx_solr.search.faceting.facetLimit
1948
     *
1949
     * @param int $defaultIfEmpty
1950
     * @return int
1951
     */
1952 31
    public function getSearchFacetingFacetLimit($defaultIfEmpty = 100)
1953
    {
1954 31
        return (int)$this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.facetLimit', $defaultIfEmpty);
1955
    }
1956
1957
    /**
1958
     * Returns if the singleFacetMode is active or not.
1959
     *
1960
     * plugin.tx_solr.search.faceting.singleFacetMode
1961
     *
1962
     * @param bool $defaultIfEmpty
1963
     * @return bool
1964
     */
1965 1
    public function getSearchFacetingSingleFacetMode($defaultIfEmpty = false)
1966
    {
1967 1
        $singleFacetMode = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.singleFacetMode', $defaultIfEmpty);
1968 1
        return $this->getBool($singleFacetMode);
1969
    }
1970
1971
    /**
1972
     * Return the configured faceting sortBy value.
1973
     *
1974
     * plugin.tx_solr.search.faceting.sortBy
1975
     *
1976
     * @param string $defaultIfEmpty
1977
     * @return string
1978
     */
1979 31
    public function getSearchFacetingSortBy($defaultIfEmpty = '')
1980
    {
1981 31
        return $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.sortBy', $defaultIfEmpty);
1982
    }
1983
1984
    /**
1985
     * Returns if a facets should be kept on selection. Global faceting setting
1986
     * can also be configured on facet level by using
1987
     * (plugin.tx_solr.search.faceting.facets.<fieldName>.keepAllOptionsOnSelection)
1988
     *
1989
     * plugin.tx_solr.search.faceting.keepAllFacetsOnSelection
1990
     *
1991
     * @param bool $defaultIfEmpty
1992
     * @return bool
1993
     */
1994 27
    public function getSearchFacetingKeepAllFacetsOnSelection($defaultIfEmpty = false)
1995
    {
1996 27
        $keepAllOptionsOnSelection = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.faceting.keepAllFacetsOnSelection', $defaultIfEmpty);
1997 27
        return $this->getBool($keepAllOptionsOnSelection);
1998
    }
1999
2000
    /**
2001
     * Returns the configured faceting configuration.
2002
     *
2003
     * plugin.tx_solr.search.faceting.facets
2004
     *
2005
     * @param array $defaultIfEmpty
2006
     * @return array
2007
     */
2008 27
    public function getSearchFacetingFacets(array $defaultIfEmpty = [])
2009
    {
2010 27
        return $this->getObjectByPathOrDefault('plugin.tx_solr.search.faceting.facets.', $defaultIfEmpty);
2011
    }
2012
2013
    /**
2014
     * Returns the configuration of a single facet by facet name.
2015
     *
2016
     * plugin.tx_solr.search.faceting.facets.<facetName>
2017
     *
2018
     * @param string $facetName
2019
     * @param array $defaultIfEmpty
2020
     * @return array
2021
     */
2022 18
    public function getSearchFacetingFacetByName($facetName, $defaultIfEmpty = [])
2023
    {
2024 18
        return $this->getObjectByPathOrDefault('plugin.tx_solr.search.faceting.facets.' . $facetName . '.', $defaultIfEmpty);
2025
    }
2026
2027
    /**
2028
     * Indicates if statistics is enabled or not.
2029
     *
2030
     * plugin.tx_solr.statistics
2031
     *
2032
     * @param bool $defaultIfEmpty
2033
     * @return bool
2034
     */
2035 24
    public function getStatistics($defaultIfEmpty = false)
2036
    {
2037 24
        $isStatisticsEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.statistics', $defaultIfEmpty);
2038 24
        return $this->getBool($isStatisticsEnabled);
2039
    }
2040
2041
    /**
2042
     * Indicates to which length an ip should be anonymized in the statistics
2043
     *
2044
     * plugin.tx_solr.statistics.anonymizeIP
2045
     *
2046
     * @param int $defaultIfEmpty
2047
     * @return int
2048
     */
2049 18
    public function getStatisticsAnonymizeIP($defaultIfEmpty = 0)
2050
    {
2051 18
        $anonymizeToLength = $this->getValueByPathOrDefaultValue('plugin.tx_solr.statistics.anonymizeIP', $defaultIfEmpty);
2052 18
        return (int)$anonymizeToLength;
2053
    }
2054
2055
    /**
2056
     * Indicates if additional debug Data should be added to the statistics
2057
     *
2058
     * plugin.tx_solr.statistics.addDebugData
2059
     *
2060
     * @param bool $defaultIfEmpty
2061
     * @return bool
2062
     */
2063 20
    public function getStatisticsAddDebugData($defaultIfEmpty = false)
2064
    {
2065 20
        $statisticsAddDebugDataEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.statistics.addDebugData', $defaultIfEmpty);
2066 20
        return $this->getBool($statisticsAddDebugDataEnabled);
2067
    }
2068
2069
    /**
2070
     * Indicates if suggestion is enabled or not.
2071
     *
2072
     * plugin.tx_solr.suggest
2073
     *
2074
     * @param bool $defaultIfEmpty
2075
     * @return bool
2076
     */
2077 25
    public function getSuggest($defaultIfEmpty = false)
2078
    {
2079 25
        $isSuggestionEnabled = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest', $defaultIfEmpty);
2080 25
        return $this->getBool($isSuggestionEnabled);
2081
    }
2082
2083
    /**
2084
     * Indicates if https should be used for the suggest form.
2085
     *
2086
     * plugin.tx_solr.suggest.forceHttps
2087
     *
2088
     * @param bool $defaultIfEmpty
2089
     * @return bool
2090
     */
2091 25
    public function getSuggestForceHttps($defaultIfEmpty = false)
2092
    {
2093 25
        $isHttpsForced = $this->getValueByPathOrDefaultValue('plugin.tx_solr.suggest.forceHttps', $defaultIfEmpty);
2094 25
        return $this->getBool($isHttpsForced);
2095
    }
2096
2097
    /**
2098
     * Returns the configured template for a specific template fileKey.
2099
     *
2100
     * plugin.tx_solr.search.templateFiles.<fileKey>
2101
     *
2102
     * @param string $fileKey
2103
     * @param string $defaultIfEmpty
2104
     * @return string
2105
     */
2106 25
    public function getTemplateByFileKey($fileKey, $defaultIfEmpty = '')
2107
    {
2108 25
        $templateFileName = $this->getValueByPathOrDefaultValue('plugin.tx_solr.templateFiles.' . $fileKey, $defaultIfEmpty);
2109 25
        return (string)$templateFileName;
2110
    }
2111
2112
    /**
2113
     * Returns the configuration of the crop view helper.
2114
     *
2115
     * plugin.tx_solr.viewHelpers.crop.
2116
     *
2117
     * @param array $defaultIfEmpty
2118
     * @return array
2119
     */
2120 1
    public function getViewHelpersCropConfiguration(array $defaultIfEmpty = [])
2121
    {
2122 1
        $cropViewHelperConfiguration = $this->getObjectByPathOrDefault('plugin.tx_solr.viewHelpers.crop.', $defaultIfEmpty);
2123 1
        return $cropViewHelperConfiguration;
2124
    }
2125
2126
    /**
2127
     * Returns the configuration of the sorting view helper.
2128
     *
2129
     * plugin.tx_solr.viewHelpers.sortIndicator.
2130
     *
2131
     * @param array $defaultIfEmpty
2132
     * @return array
2133
     */
2134 17
    public function getViewHelpersSortIndicatorConfiguration(array $defaultIfEmpty = [])
2135
    {
2136 17
        $sortingViewHelperConfiguration = $this->getObjectByPathOrDefault('plugin.tx_solr.viewHelpers.sortIndicator.', $defaultIfEmpty);
2137 17
        return $sortingViewHelperConfiguration;
2138
    }
2139
2140
    /**
2141
     * Controls whether ext-solr will send commits to solr.
2142
     * Beware: If you disable this, you need to ensure
2143
     * that some other mechanism will commit your changes
2144
     * otherwise they will never be searchable.
2145
     * A good way to achieve this is enabling the solr
2146
     * daemons autoCommit feature.
2147
     *
2148
     * plugin.tx_solr.index.enableCommits
2149
     *
2150
     * @param bool $defaultIfEmpty
2151
     * @return bool
2152
     */
2153 11
    public function getEnableCommits($defaultIfEmpty = true)
2154
    {
2155 11
        $enableCommits = $this->getValueByPathOrDefaultValue('plugin.tx_solr.index.enableCommits', $defaultIfEmpty);
2156 11
        $this->getBool($enableCommits);
2157 11
    }
2158
2159
    /*
2160
     * Applies the stdWrap if it is configured for the path, otherwise the unprocessed value will be returned.
2161
     *
2162
     * @param string $valuePath
2163
     * @param mixed $value
2164
     * @return mixed
2165
     */
2166 7
    protected function renderContentElementOfConfigured($valuePath, $value)
2167
    {
2168 7
        $configurationPath = $valuePath . '.';
2169 7
        $configuration = $this->getObjectByPath($configurationPath);
2170
2171 7
        if ($configuration == null) {
2172 5
            return $value;
2173
        }
2174
2175 2
        return $this->contentObjectService->renderSingleContentObject($value, $configuration);
2176
    }
2177
}
2178