Completed
Push — master ( 1ccb29...3a83fd )
by Timo
8s
created

getIndexQueueAdditionalPageIdsByConfigurationName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

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