Passed
Push — release-11.5.x ( bc6a4d...d54a47 )
by Rafael
30:54 queued 07:27
created

SearchRequest::removeAllGroupItemPages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
18
namespace ApacheSolrForTypo3\Solr\Domain\Search;
19
20
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\UrlFacetContainer;
21
use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration;
22
use ApacheSolrForTypo3\Solr\System\Util\ArrayAccessor;
23
use TYPO3\CMS\Core\Utility\ArrayUtility;
24
use TYPO3\CMS\Core\Utility\GeneralUtility;
25
26
/**
27
 * The searchRequest is used to act as an api to the arguments that have been passed
28
 * with GET and POST.
29
 *
30
 * @author Timo Schmidt <[email protected]>
31
 */
32
class SearchRequest
33
{
34
    /**
35
     * The default plugin namespace.
36
     *
37
     * @var string
38
     */
39
    const DEFAULT_PLUGIN_NAMESPACE = 'tx_solr';
40
41
    /**
42
     * @var string
43
     */
44
    protected string $id;
45
46
    /**
47
     * Default namespace overwritten with the configured plugin namespace.
48
     *
49
     * @var string
50
     */
51
    protected string $argumentNameSpace = self::DEFAULT_PLUGIN_NAMESPACE;
52
53
    /**
54
     * Arguments that should be kept for sub requests.
55
     *
56
     * Default values, overwritten in the constructor with the namespaced arguments
57
     *
58
     * @var array
59
     */
60
    protected array $persistentArgumentsPaths = [
61
        'tx_solr:q',
62
        'tx_solr:filter',
63
        'tx_solr:sort',
64
    ];
65
66
    /**
67
     * @var bool
68
     */
69
    protected bool $stateChanged = false;
70
71
    /**
72
     * @var ArrayAccessor|null
73
     */
74
    protected ?ArrayAccessor $argumentsAccessor = null;
75
76
    /**
77
     * The sys_language_uid that was used in the context where the request was build.
78
     * This could be different from the "L" parameter and not relevant for urls,
79
     * because typolink itself will handle it.
80
     *
81
     * @var int
82
     */
83
    protected int $contextSystemLanguageUid = 0;
84
85
    /**
86
     * The page_uid that was used in the context where the request was build.
87
     *
88
     * The pageUid is not relevant for the typolink additionalArguments and therefore
89
     * a separate property.
90
     *
91
     * @var int
92
     */
93
    protected int $contextPageUid;
94
95
    /**
96
     * @var TypoScriptConfiguration|null
97
     */
98
    protected ?TypoScriptConfiguration $contextTypoScriptConfiguration;
99
100
    /**
101
     * Container for all active facets inside the URL(TYPO3/FE)
102
     *
103
     * @var UrlFacetContainer|null
104
     */
105
    protected ?UrlFacetContainer $activeFacetContainer;
106
107
    /**
108
     * @var array
109
     */
110
    protected array $persistedArguments = [];
111
112
    /**
113
     * @param array $argumentsArray
114
     * @param int $pageUid
115
     * @param int $sysLanguageUid
116
     * @param TypoScriptConfiguration|null $typoScriptConfiguration
117
     */
118 105
    public function __construct(
119
        array $argumentsArray = [],
120
        int $pageUid = 0,
121
        int $sysLanguageUid = 0,
122
        TypoScriptConfiguration $typoScriptConfiguration = null
123
    ) {
124 105
        $this->stateChanged = true;
125 105
        $this->persistedArguments = $argumentsArray;
126 105
        $this->contextPageUid = $pageUid;
127 105
        $this->contextSystemLanguageUid = $sysLanguageUid;
128 105
        $this->contextTypoScriptConfiguration = $typoScriptConfiguration;
129 105
        $this->id = spl_object_hash($this);
130
131
        // overwrite the plugin namespace and the persistentArgumentsPaths
132 105
        if (!is_null($typoScriptConfiguration)) {
133 55
            $this->argumentNameSpace = $typoScriptConfiguration->getSearchPluginNamespace() ?? self::DEFAULT_PLUGIN_NAMESPACE;
134
        }
135
136 105
        $this->persistentArgumentsPaths = [$this->argumentNameSpace . ':q', $this->argumentNameSpace . ':filter', $this->argumentNameSpace . ':sort', $this->argumentNameSpace . ':groupPage'];
137
138 105
        if (!is_null($typoScriptConfiguration)) {
139 55
            $additionalPersistentArgumentsNames = $typoScriptConfiguration->getSearchAdditionalPersistentArgumentNames();
140 55
            foreach ($additionalPersistentArgumentsNames ?? [] as $additionalPersistentArgumentsName) {
141
                $this->persistentArgumentsPaths[] = $this->argumentNameSpace . ':' . $additionalPersistentArgumentsName;
142
            }
143 55
            $this->persistentArgumentsPaths = array_unique($this->persistentArgumentsPaths);
144
        }
145
146 105
        $this->reset();
147
    }
148
149
    /**
150
     * @return string
151
     */
152 21
    public function getId(): string
153
    {
154 21
        return $this->id;
155
    }
156
157
    /**
158
     * Can be used do merge arguments into the request arguments
159
     *
160
     * @param array $argumentsToMerge
161
     * @return SearchRequest
162
     */
163 1
    public function mergeArguments(array $argumentsToMerge): SearchRequest
164
    {
165 1
        ArrayUtility::mergeRecursiveWithOverrule(
166 1
            $this->persistedArguments,
167 1
            $argumentsToMerge
168 1
        );
169
170 1
        $this->reset();
171
172 1
        return $this;
173
    }
174
175
    /**
176
     * Helper method to prefix an accessor with the argument's namespace.
177
     *
178
     * @param string $path
179
     * @return string
180
     */
181 79
    protected function prefixWithNamespace(string $path): string
182
    {
183 79
        return $this->argumentNameSpace . ':' . $path;
184
    }
185
186
    /**
187
     * @return array
188
     */
189 2
    public function getActiveFacetNames(): array
190
    {
191 2
        return $this->activeFacetContainer->getActiveFacetNames();
0 ignored issues
show
Bug introduced by
The method getActiveFacetNames() does not exist on null. ( Ignorable by Annotation )

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

191
        return $this->activeFacetContainer->/** @scrutinizer ignore-call */ getActiveFacetNames();

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

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

Loading history...
192
    }
193
194
    /**
195
     * Returns all facet values for a certain facetName
196
     * @param string $facetName
197
     * @return array
198
     */
199 18
    public function getActiveFacetValuesByName(string $facetName): array
200
    {
201 18
        return $this->activeFacetContainer->getActiveFacetValuesByName($facetName);
202
    }
203
204
    /**
205
     * @return array
206
     */
207
    public function getActiveFacets(): array
208
    {
209
        return $this->activeFacetContainer->getActiveFacets();
210
    }
211
212
    /**
213
     * Enable sorting of URL parameters
214
     * @noinspection PhpUnused
215
     */
216
    public function sortActiveFacets(): void
217
    {
218
        $this->activeFacetContainer->enableSort();
219
    }
220
221
    /**
222
     * @return bool
223
     */
224 23
    public function isActiveFacetsSorted(): bool
225
    {
226 23
        return $this->activeFacetContainer->isSorted();
227
    }
228
229
    /**
230
     * @return string
231
     */
232
    public function getActiveFacetsUrlParameterStyle(): string
233
    {
234
        return $this->activeFacetContainer->getParameterStyle();
235
    }
236
237
    /**
238
     * Returns the active count of facets
239
     *
240
     * @return int
241
     */
242 2
    public function getActiveFacetCount(): int
243
    {
244 2
        return $this->activeFacetContainer->count();
245
    }
246
247
    /**
248
     * @param array $activeFacets
249
     *
250
     * @return SearchRequest
251
     * @noinspection PhpUnused
252
     */
253
    protected function setActiveFacets(array $activeFacets = []): SearchRequest
254
    {
255
        $this->activeFacetContainer->setActiveFacets($activeFacets);
256
257
        return $this;
258
    }
259
260
    /**
261
     * Adds a facet value to the request.
262
     *
263
     * @param string $facetName
264
     * @param mixed $facetValue
265
     *
266
     * @return SearchRequest
267
     */
268 25
    public function addFacetValue(string $facetName, $facetValue): SearchRequest
269
    {
270 25
        $this->activeFacetContainer->addFacetValue($facetName, $facetValue);
271
272 25
        if ($this->activeFacetContainer->hasChanged()) {
273 24
            $this->stateChanged = true;
274 24
            $this->activeFacetContainer->acknowledgeChange();
275
        }
276
277 25
        return $this;
278
    }
279
280
    /**
281
     * Removes a facet value from the request.
282
     *
283
     * @param string $facetName
284
     * @param mixed $facetValue
285
     *
286
     * @return SearchRequest
287
     */
288 6
    public function removeFacetValue(string $facetName, $facetValue): SearchRequest
289
    {
290 6
        $this->activeFacetContainer->removeFacetValue($facetName, $facetValue);
291 6
        if ($this->activeFacetContainer->hasChanged()) {
292 6
            $this->stateChanged = true;
293 6
            $this->activeFacetContainer->acknowledgeChange();
294
        }
295
296 6
        return $this;
297
    }
298
299
    /**
300
     * Removes all facet values from the request by a certain facet name
301
     *
302
     * @param string $facetName
303
     *
304
     * @return SearchRequest
305
     */
306 3
    public function removeAllFacetValuesByName(string $facetName): SearchRequest
307
    {
308 3
        $this->activeFacetContainer->removeAllFacetValuesByName($facetName);
309 3
        if ($this->activeFacetContainer->hasChanged()) {
310 3
            $this->stateChanged = true;
311 3
            $this->activeFacetContainer->acknowledgeChange();
312
        }
313 3
        return $this;
314
    }
315
316
    /**
317
     * Removes all active facets from the request.
318
     *
319
     * @return SearchRequest
320
     */
321 6
    public function removeAllFacets(): SearchRequest
322
    {
323 6
        $this->activeFacetContainer->removeAllFacets();
324 6
        if ($this->activeFacetContainer->hasChanged()) {
325 6
            $this->stateChanged = true;
326 6
            $this->activeFacetContainer->acknowledgeChange();
327
        }
328 6
        return $this;
329
    }
330
331
    /**
332
     * Check if an active facet has a given value
333
     *
334
     * @param string $facetName
335
     * @param mixed $facetValue
336
     * @return bool
337
     */
338 2
    public function getHasFacetValue(string $facetName, $facetValue): bool
339
    {
340 2
        return $this->activeFacetContainer->hasFacetValue($facetName, $facetValue);
341
    }
342
343
    /**
344
     * Returns all sortings in the sorting string e.g. ['title' => 'asc', 'relevance' => 'desc']
345
     */
346 41
    public function getSeperatedSortings(): array
347
    {
348 41
        $parsedSortings = [];
349 41
        $explodedSortings = GeneralUtility::trimExplode(',', $this->getSorting(), true);
350
351 41
        foreach ($explodedSortings as $sorting) {
352
            $sortingSeperated = explode(' ', $sorting);
353
            if (count($sortingSeperated) === 2) {
354
                $parsedSortings[$sortingSeperated[0]] = $sortingSeperated[1];
355
            }
356
        }
357
358 41
        return $parsedSortings;
359
    }
360
361
    /**
362
     * @return bool
363
     */
364 44
    public function getHasSorting(): bool
365
    {
366 44
        $path = $this->prefixWithNamespace('sort');
367 44
        return $this->argumentsAccessor->has($path);
0 ignored issues
show
Bug introduced by
The method has() does not exist on null. ( Ignorable by Annotation )

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

367
        return $this->argumentsAccessor->/** @scrutinizer ignore-call */ has($path);

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

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

Loading history...
368
    }
369
370
    /**
371
     * Returns the sorting string in the url e.g. title asc.
372
     *
373
     * @return string
374
     */
375 43
    public function getSorting(): string
376
    {
377 43
        $path = $this->prefixWithNamespace('sort');
378 43
        return $this->argumentsAccessor->get($path, '');
379
    }
380
381
    /**
382
     * Helper function to get the sorting configuration name or direction.
383
     *
384
     * @param int $index
385
     * @return string
386
     */
387 2
    protected function getSortingPart(int $index): ?string
388
    {
389 2
        $sorting = $this->getSorting();
390 2
        if ($sorting === '') {
391
            return null;
392
        }
393
394 2
        $parts = explode(' ', $sorting);
395 2
        return $parts[$index] ?? null;
396
    }
397
398
    /**
399
     * Returns the sorting configuration name that is currently used.
400
     *
401
     * @return string
402
     */
403 2
    public function getSortingName(): ?string
404
    {
405 2
        return $this->getSortingPart(0);
406
    }
407
408
    /**
409
     * Returns the sorting direction that is currently used.
410
     *
411
     * @return string
412
     */
413 1
    public function getSortingDirection(): string
414
    {
415 1
        return mb_strtolower($this->getSortingPart(1) ?? '');
416
    }
417
418
    /**
419
     * @return SearchRequest
420
     */
421 1
    public function removeSorting(): SearchRequest
422
    {
423 1
        $path = $this->prefixWithNamespace('sort');
424 1
        $this->argumentsAccessor->reset($path);
425 1
        $this->stateChanged = true;
426 1
        return $this;
427
    }
428
429
    /**
430
     * @param string $sortingName
431
     * @param string $direction (asc or desc)
432
     *
433
     * @return SearchRequest
434
     */
435 2
    public function setSorting(string $sortingName, string $direction = 'asc'): SearchRequest
436
    {
437 2
        $value = $sortingName . ' ' . $direction;
438 2
        $path = $this->prefixWithNamespace('sort');
439 2
        $this->argumentsAccessor->set($path, $value);
440 2
        $this->stateChanged = true;
441 2
        return $this;
442
    }
443
444
    /**
445
     * Method to set the paginated page of the search
446
     *
447
     * @param int $page
448
     * @return SearchRequest
449
     */
450 7
    public function setPage(int $page): SearchRequest
451
    {
452 7
        $this->stateChanged = true;
453 7
        $path = $this->prefixWithNamespace('page');
454 7
        $this->argumentsAccessor->set($path, $page);
455
        // use initial url by switching back to page 0
456 7
        if ($page === 0) {
457 5
            $this->argumentsAccessor->reset($path);
458
        }
459 7
        return $this;
460
    }
461
462
    /**
463
     * Returns the passed page.
464
     *
465
     * @return int|null
466
     */
467 52
    public function getPage(): ?int
468
    {
469 52
        $path = $this->prefixWithNamespace('page');
470 52
        return $this->argumentsAccessor->get($path);
471
    }
472
473
    /**
474
     * Can be used to reset all groupPages.
475
     *
476
     * @return SearchRequest
477
     */
478 23
    public function removeAllGroupItemPages(): SearchRequest
479
    {
480 23
        $path = $this->prefixWithNamespace('groupPage');
481 23
        $this->argumentsAccessor->reset($path);
482
483 23
        return $this;
484
    }
485
486
    /**
487
     * Can be used to paginate within a groupItem.
488
     *
489
     * @param string $groupName e.g. type
490
     * @param string $groupItemValue e.g. pages
491
     * @param int $page
492
     * @return SearchRequest
493
     */
494 4
    public function setGroupItemPage(string $groupName, string $groupItemValue, int $page): SearchRequest
495
    {
496 4
        $this->stateChanged = true;
497 4
        $escapedValue = $this->getEscapedGroupItemValue($groupItemValue);
498 4
        $path = $this->prefixWithNamespace('groupPage:' . $groupName . ':' . $escapedValue);
499 4
        $this->argumentsAccessor->set($path, $page);
500 4
        return $this;
501
    }
502
503
    /**
504
     * Retrieves the current page for this group item.
505
     *
506
     * @param string $groupName
507
     * @param string $groupItemValue
508
     * @return int
509
     */
510 3
    public function getGroupItemPage(string $groupName, string $groupItemValue): int
511
    {
512 3
        $escapedValue = $this->getEscapedGroupItemValue($groupItemValue);
513 3
        $path = $this->prefixWithNamespace('groupPage:' . $groupName . ':' . $escapedValue);
514 3
        return max(1, (int)$this->argumentsAccessor->get($path));
515
    }
516
517
    /**
518
     * Removes all non-alphanumeric values from the groupItem value to have a valid array key.
519
     *
520
     * @param string $groupItemValue
521
     * @return string
522
     */
523 5
    protected function getEscapedGroupItemValue(string $groupItemValue): string
524
    {
525 5
        return preg_replace('/[^A-Za-z0-9]/', '', $groupItemValue);
526
    }
527
528
    /**
529
     * Retrieves the highest page of the groups.
530
     *
531
     * @return int
532
     */
533 1
    public function getHighestGroupPage(): int
534
    {
535 1
        $max = 1;
536 1
        $path = $this->prefixWithNamespace('groupPage');
537 1
        $groupPages = $this->argumentsAccessor->get($path, []);
538 1
        foreach ($groupPages as $groups) {
539
            if (!is_array($groups)) {
540
                continue;
541
            }
542
            foreach ($groups as $groupItemPage) {
543
                if ((int)$groupItemPage > $max) {
544
                    $max = (int)$groupItemPage;
545
                }
546
            }
547
        }
548
549 1
        return $max;
550
    }
551
552
    /**
553
     * Method to overwrite the query string.
554
     *
555
     * @param string $rawQueryString
556
     * @return SearchRequest
557
     */
558 17
    public function setRawQueryString(string $rawQueryString = ''): SearchRequest
559
    {
560 17
        $this->stateChanged = true;
561 17
        $path = $this->prefixWithNamespace('q');
562 17
        $this->argumentsAccessor->set($path, $rawQueryString);
563 17
        return $this;
564
    }
565
566
    /**
567
     * Returns the passed rawQueryString.
568
     *
569
     * @return string
570
     */
571 44
    public function getRawUserQuery(): string
572
    {
573 44
        $path = $this->prefixWithNamespace('q');
574 44
        $query = $this->argumentsAccessor->get($path);
575 44
        return (string)($query ?? '');
576
    }
577
578
    /**
579
     * Method to check if the query string is an empty string
580
     * (also empty string or whitespaces only are handled as empty).
581
     *
582
     * When no query string is set (null) the method returns false.
583
     * @return bool
584
     */
585 43
    public function getRawUserQueryIsEmptyString(): bool
586
    {
587 43
        $path = $this->prefixWithNamespace('q');
588 43
        $query = $this->argumentsAccessor->get($path);
589
590 43
        if ($query === null) {
591 3
            return false;
592
        }
593
594 40
        if (trim($query) === '') {
595 2
            return true;
596
        }
597
598 38
        return false;
599
    }
600
601
    /**
602
     * This method returns true when no querystring is present at all.
603
     * Which means no search by the user was triggered
604
     *
605
     * @return bool
606
     */
607 49
    public function getRawUserQueryIsNull(): bool
608
    {
609 49
        $path = $this->prefixWithNamespace('q');
610 49
        $query = $this->argumentsAccessor->get($path);
611 49
        return $query === null;
612
    }
613
614
    /**
615
     * Sets the results per page that are used during search.
616
     *
617
     * @param int $resultsPerPage
618
     * @return SearchRequest
619
     */
620 50
    public function setResultsPerPage(int $resultsPerPage): SearchRequest
621
    {
622 50
        $path = $this->prefixWithNamespace('resultsPerPage');
623 50
        $this->argumentsAccessor->set($path, $resultsPerPage);
624 50
        $this->stateChanged = true;
625
626 50
        return $this;
627
    }
628
629
    /**
630
     * @return bool
631
     */
632 1
    public function getStateChanged(): bool
633
    {
634 1
        return $this->stateChanged;
635
    }
636
637
    /**
638
     * Returns the passed resultsPerPage value
639
     * @return int
640
     */
641 51
    public function getResultsPerPage(): int
642
    {
643 51
        $path = $this->prefixWithNamespace('resultsPerPage');
644 51
        return (int)$this->argumentsAccessor->get($path);
645
    }
646
647
    /**
648
     * Allows setting additional filters that are used on time and not transported during the request.
649
     *
650
     * @param array $additionalFilters
651
     * @return SearchRequest
652
     */
653 3
    public function setAdditionalFilters(array $additionalFilters): SearchRequest
654
    {
655 3
        $path = $this->prefixWithNamespace('additionalFilters');
656 3
        $this->argumentsAccessor->set($path, $additionalFilters);
657 3
        $this->stateChanged = true;
658
659 3
        return $this;
660
    }
661
662
    /**
663
     * Retrieves the additional filters that have been set
664
     *
665
     * @return array
666
     */
667 41
    public function getAdditionalFilters(): array
668
    {
669 41
        $path = $this->prefixWithNamespace('additionalFilters');
670 41
        return $this->argumentsAccessor->get($path, []);
671
    }
672
673
    /**
674
     * @return int
675
     */
676 2
    public function getContextSystemLanguageUid(): int
677
    {
678 2
        return $this->contextSystemLanguageUid;
679
    }
680
681
    /**
682
     * @return int
683
     */
684 2
    public function getContextPageUid(): int
685
    {
686 2
        return $this->contextPageUid;
687
    }
688
689
    /**
690
     * Get contextTypoScriptConfiguration
691
     *
692
     * @return TypoScriptConfiguration
693
     */
694 55
    public function getContextTypoScriptConfiguration(): ?TypoScriptConfiguration
695
    {
696 55
        return $this->contextTypoScriptConfiguration;
697
    }
698
699
    /**
700
     * Assigns the last known persistedArguments and restores their state.
701
     *
702
     * @return SearchRequest
703
     */
704 105
    public function reset(): SearchRequest
705
    {
706 105
        $this->argumentsAccessor = new ArrayAccessor($this->persistedArguments);
707 105
        $this->stateChanged = false;
708 105
        $this->activeFacetContainer = new UrlFacetContainer(
709 105
            $this->argumentsAccessor,
710 105
            $this->argumentNameSpace ?? self::DEFAULT_PLUGIN_NAMESPACE,
711 105
            $this->contextTypoScriptConfiguration === null ?
712 51
                UrlFacetContainer::PARAMETER_STYLE_INDEX :
713 105
                $this->contextTypoScriptConfiguration->getSearchFacetingUrlParameterStyle()
714 105
        );
715
716
        // If the default of sorting parameter should be true, a modification of this condition is needed.
717
        // If instance of contextTypoScriptConfiguration is not TypoScriptConfiguration the sort should be enabled too
718 105
        if ($this->contextTypoScriptConfiguration instanceof TypoScriptConfiguration
719 105
            && $this->contextTypoScriptConfiguration->getSearchFacetingUrlParameterSort()
720
        ) {
721
            $this->activeFacetContainer->enableSort();
722
        }
723
724 105
        return $this;
725
    }
726
727
    /**
728
     * This can be used to start a new sub request, e.g. for a faceted search.
729
     *
730
     * @param bool $onlyPersistentArguments
731
     * @return SearchRequest
732
     */
733 40
    public function getCopyForSubRequest(bool $onlyPersistentArguments = true): SearchRequest
734
    {
735 40
        if (!$onlyPersistentArguments) {
736
            // create a new request with all data
737
            $argumentsArray = $this->argumentsAccessor->getData();
738
            return new SearchRequest(
739
                $argumentsArray,
740
                $this->contextPageUid,
741
                $this->contextSystemLanguageUid,
742
                $this->contextTypoScriptConfiguration
743
            );
744
        }
745
746 40
        $arguments = new ArrayAccessor();
747 40
        foreach ($this->persistentArgumentsPaths as $persistentArgumentPath) {
748 40
            if ($this->argumentsAccessor->has($persistentArgumentPath)) {
749 32
                $arguments->set($persistentArgumentPath, $this->argumentsAccessor->get($persistentArgumentPath));
750
            }
751
        }
752
753 40
        return new SearchRequest(
754 40
            $arguments->getData(),
755 40
            $this->contextPageUid,
756 40
            $this->contextSystemLanguageUid,
757 40
            $this->contextTypoScriptConfiguration
758 40
        );
759
    }
760
761
    /**
762
     * @return string
763
     * @noinspection PhpUnused
764
     */
765 22
    public function getArgumentNamespace(): string
766
    {
767 22
        return $this->argumentNameSpace;
768
    }
769
770
    /**
771
     * @return array
772
     */
773 44
    public function getAsArray(): array
774
    {
775 44
        return $this->argumentsAccessor->getData();
776
    }
777
778
    /**
779
     * Returns only the arguments as array.
780
     *
781
     * @return array
782
     */
783 17
    public function getArguments(): array
784
    {
785 17
        return $this->argumentsAccessor->get($this->argumentNameSpace) ?? [];
786
    }
787
}
788