Completed
Pull Request — master (#878)
by Timo
33:19 queued 29:07
created

getSolrHasConnectionConfiguration()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

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