‪TYPO3CMS  11.5
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 
22 use TYPO3Fluid\Fluid\View\ViewInterface;
23 
30 {
31  protected ViewInterface ‪$view;
32  protected array ‪$allowedSearchLevels = [];
33  protected string ‪$searchWord = '';
34  protected int ‪$searchLevel = 0;
35 
36  public function ‪__construct(?ViewInterface ‪$view = null)
37  {
38  $this->view = ‪$view ?? $this->‪getView('Search.html');
39  }
40 
41  public function ‪setSearchWord(string $searchWord): self
42  {
43  $this->searchWord = ‪$searchWord;
44  return $this;
45  }
46 
47  public function ‪setSearchLevel(int ‪$searchLevel): self
48  {
49  $this->searchLevel = ‪$searchLevel;
50  return $this;
51  }
52 
54  {
55  $this->allowedSearchLevels = ‪$allowedSearchLevels;
56  return $this;
57  }
58 
59  public function ‪render(string $formUrl = ''): string
60  {
61  return $this->view
62  ->assignMultiple([
63  'formUrl' => $formUrl,
64  'availableSearchLevels' => $this->allowedSearchLevels,
65  'selectedSearchLevel' => $this->searchLevel,
66  'searchString' => $this->searchWord,
67  ])
68  ->render();
69  }
70 
71  protected function ‪getView(string $filename): ‪StandaloneView
72  {
73  ‪$view = GeneralUtility::makeInstance(StandaloneView::class);
74  ‪$view->setTemplateRootPaths(['EXT:recordlist/Resources/Private/Templates']);
75  ‪$view->setTemplate($filename);
76  return ‪$view;
77  }
78 }
‪TYPO3\CMS\Recordlist\View\RecordSearchBoxComponent\__construct
‪__construct(?ViewInterface $view=null)
Definition: RecordSearchBoxComponent.php:36
‪TYPO3\CMS\Recordlist\View
Definition: FolderUtilityRenderer.php:16
‪TYPO3\CMS\Recordlist\View\RecordSearchBoxComponent\setSearchWord
‪setSearchWord(string $searchWord)
Definition: RecordSearchBoxComponent.php:41
‪TYPO3\CMS\Recordlist\View\RecordSearchBoxComponent\getView
‪getView(string $filename)
Definition: RecordSearchBoxComponent.php:71
‪TYPO3\CMS\Recordlist\View\RecordSearchBoxComponent\setAllowedSearchLevels
‪setAllowedSearchLevels(array $allowedSearchLevels)
Definition: RecordSearchBoxComponent.php:53
‪TYPO3\CMS\Recordlist\View\RecordSearchBoxComponent\$searchLevel
‪int $searchLevel
Definition: RecordSearchBoxComponent.php:34
‪TYPO3\CMS\Recordlist\View\RecordSearchBoxComponent\render
‪render(string $formUrl='')
Definition: RecordSearchBoxComponent.php:59
‪TYPO3\CMS\Recordlist\View\RecordSearchBoxComponent\setSearchLevel
‪setSearchLevel(int $searchLevel)
Definition: RecordSearchBoxComponent.php:47
‪TYPO3\CMS\Recordlist\View\RecordSearchBoxComponent\$searchWord
‪string $searchWord
Definition: RecordSearchBoxComponent.php:33
‪TYPO3\CMS\Recordlist\View\RecordSearchBoxComponent
Definition: RecordSearchBoxComponent.php:30
‪TYPO3\CMS\Recordlist\View\RecordSearchBoxComponent\$allowedSearchLevels
‪array $allowedSearchLevels
Definition: RecordSearchBoxComponent.php:32
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:31
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Recordlist\View\RecordSearchBoxComponent\$view
‪ViewInterface $view
Definition: RecordSearchBoxComponent.php:31