‪TYPO3CMS  10.4
FileSearchDemand.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 
21 
26 {
30  private ‪$searchTerm;
31 
35  private ‪$folder;
36 
40  private ‪$firstResult;
41 
45  private ‪$maxResults;
46 
50  private ‪$searchFields;
51 
55  private ‪$orderings;
56 
60  private ‪$recursive = false;
61 
67  private function ‪__construct(string ‪$searchTerm = null)
68  {
69  $this->searchTerm = ‪$searchTerm;
70  }
71 
72  public static function ‪create(): self
73  {
74  return new self();
75  }
76 
77  public static function ‪createForSearchTerm(string ‪$searchTerm): self
78  {
79  return new self(‪$searchTerm);
80  }
81 
82  public function ‪getSearchTerm(): ?string
83  {
84  return ‪$this->searchTerm;
85  }
86 
87  public function ‪getFolder(): ?‪Folder
88  {
89  return ‪$this->folder;
90  }
91 
92  public function ‪getFirstResult(): ?int
93  {
94  return ‪$this->firstResult;
95  }
96 
97  public function ‪getMaxResults(): ?int
98  {
99  return ‪$this->maxResults;
100  }
101 
102  public function ‪getSearchFields(): ?array
103  {
104  return ‪$this->searchFields;
105  }
106 
107  public function ‪getOrderings(): ?array
108  {
109  return ‪$this->orderings;
110  }
111 
112  public function ‪isRecursive(): bool
113  {
114  return ‪$this->recursive;
115  }
116 
117  public function ‪withSearchTerm(string ‪$searchTerm): self
118  {
119  $demand = clone $this;
120  $demand->searchTerm = ‪$searchTerm;
121 
122  return $demand;
123  }
124 
125  public function ‪withFolder(‪Folder ‪$folder): self
126  {
127  $demand = clone $this;
128  $demand->folder = ‪$folder;
129 
130  return $demand;
131  }
132 
140  public function ‪withStartResult(int ‪$firstResult): self
141  {
142  $demand = clone $this;
143  $demand->firstResult = ‪$firstResult;
144 
145  return $demand;
146  }
147 
148  public function ‪withMaxResults(int ‪$maxResults): self
149  {
150  $demand = clone $this;
151  $demand->maxResults = ‪$maxResults;
152 
153  return $demand;
154  }
155 
156  public function ‪addSearchField(string $tableName, string $field): self
157  {
158  $demand = clone $this;
159  $demand->searchFields[$tableName] = $field;
160 
161  return $demand;
162  }
163 
164  public function ‪addOrdering(string $tableName, string $fieldName, string $direction = 'ASC'): self
165  {
166  $demand = clone $this;
167  $demand->orderings[] = [$tableName, $fieldName, $direction];
168 
169  return $demand;
170  }
171 
172  public function ‪withRecursive(): self
173  {
174  $demand = clone $this;
175  $demand->recursive = true;
176 
177  return $demand;
178  }
179 }
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\withSearchTerm
‪withSearchTerm(string $searchTerm)
Definition: FileSearchDemand.php:110
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\addSearchField
‪addSearchField(string $tableName, string $field)
Definition: FileSearchDemand.php:149
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\withStartResult
‪FileSearchDemand withStartResult(int $firstResult)
Definition: FileSearchDemand.php:133
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\isRecursive
‪isRecursive()
Definition: FileSearchDemand.php:105
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\$searchFields
‪array null $searchFields
Definition: FileSearchDemand.php:45
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\addOrdering
‪addOrdering(string $tableName, string $fieldName, string $direction='ASC')
Definition: FileSearchDemand.php:157
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\withFolder
‪withFolder(Folder $folder)
Definition: FileSearchDemand.php:118
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\getFirstResult
‪getFirstResult()
Definition: FileSearchDemand.php:85
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\$firstResult
‪int null $firstResult
Definition: FileSearchDemand.php:37
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\create
‪static create()
Definition: FileSearchDemand.php:65
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\getSearchFields
‪getSearchFields()
Definition: FileSearchDemand.php:95
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand
Definition: FileSearchDemand.php:26
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:37
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\$orderings
‪array null $orderings
Definition: FileSearchDemand.php:49
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\withMaxResults
‪withMaxResults(int $maxResults)
Definition: FileSearchDemand.php:141
‪TYPO3\CMS\Core\Resource\Search
Definition: FileSearchDemand.php:18
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\getFolder
‪getFolder()
Definition: FileSearchDemand.php:80
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\$recursive
‪bool $recursive
Definition: FileSearchDemand.php:53
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\__construct
‪__construct(string $searchTerm=null)
Definition: FileSearchDemand.php:60
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\$maxResults
‪int null $maxResults
Definition: FileSearchDemand.php:41
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\getMaxResults
‪getMaxResults()
Definition: FileSearchDemand.php:90
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\getOrderings
‪getOrderings()
Definition: FileSearchDemand.php:100
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\getSearchTerm
‪getSearchTerm()
Definition: FileSearchDemand.php:75
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\createForSearchTerm
‪static createForSearchTerm(string $searchTerm)
Definition: FileSearchDemand.php:70
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\$searchTerm
‪string null $searchTerm
Definition: FileSearchDemand.php:29
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\$folder
‪Folder null $folder
Definition: FileSearchDemand.php:33
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\withRecursive
‪withRecursive()
Definition: FileSearchDemand.php:165