‪TYPO3CMS  ‪main
RecordSearchBoxComponent.php
Go to the documentation of this file.
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 
19 
20 use Psr\Http\Message\ServerRequestInterface;
21 
28 {
29  protected array ‪$allowedSearchLevels = [];
30  protected string ‪$searchWord = '';
31  protected int ‪$searchLevel = 0;
32 
33  public function ‪__construct(protected readonly ‪BackendViewFactory $backendViewFactory) {}
34 
35  public function ‪setSearchWord(string ‪$searchWord): self
36  {
37  $this->searchWord = ‪$searchWord;
38  return $this;
39  }
40 
41  public function ‪setSearchLevel(int ‪$searchLevel): self
42  {
43  $this->searchLevel = ‪$searchLevel;
44  return $this;
45  }
46 
48  {
49  $this->allowedSearchLevels = ‪$allowedSearchLevels;
50  return $this;
51  }
52 
53  public function ‪render(ServerRequestInterface $request, string $formUrl = ''): string
54  {
55  $view = $this->backendViewFactory->create($request, ['typo3/cms-backend']);
56  return $view
57  ->assignMultiple([
58  'formUrl' => $formUrl,
59  'availableSearchLevels' => $this->allowedSearchLevels,
60  'selectedSearchLevel' => $this->searchLevel,
61  'searchString' => $this->searchWord,
62  ])
63  ->render('RecordSearchBox');
64  }
65 }
‪TYPO3\CMS\Backend\View\RecordSearchBoxComponent\$searchLevel
‪int $searchLevel
Definition: RecordSearchBoxComponent.php:31
‪TYPO3\CMS\Backend\View\RecordSearchBoxComponent\render
‪render(ServerRequestInterface $request, string $formUrl='')
Definition: RecordSearchBoxComponent.php:53
‪TYPO3\CMS\Backend\View\BackendViewFactory
Definition: BackendViewFactory.php:35
‪TYPO3\CMS\Backend\View\RecordSearchBoxComponent\$searchWord
‪string $searchWord
Definition: RecordSearchBoxComponent.php:30
‪TYPO3\CMS\Backend\View
Definition: AuthenticationStyleInformation.php:18
‪TYPO3\CMS\Backend\View\RecordSearchBoxComponent\setSearchWord
‪setSearchWord(string $searchWord)
Definition: RecordSearchBoxComponent.php:35
‪TYPO3\CMS\Backend\View\RecordSearchBoxComponent\setAllowedSearchLevels
‪setAllowedSearchLevels(array $allowedSearchLevels)
Definition: RecordSearchBoxComponent.php:47
‪TYPO3\CMS\Backend\View\RecordSearchBoxComponent\setSearchLevel
‪setSearchLevel(int $searchLevel)
Definition: RecordSearchBoxComponent.php:41
‪TYPO3\CMS\Backend\View\RecordSearchBoxComponent
Definition: RecordSearchBoxComponent.php:28
‪TYPO3\CMS\Backend\View\RecordSearchBoxComponent\__construct
‪__construct(protected readonly BackendViewFactory $backendViewFactory)
Definition: RecordSearchBoxComponent.php:33
‪TYPO3\CMS\Backend\View\RecordSearchBoxComponent\$allowedSearchLevels
‪array $allowedSearchLevels
Definition: RecordSearchBoxComponent.php:29