‪TYPO3CMS  ‪main
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 
137  public function ‪withStartResult(int ‪$firstResult): self
138  {
139  $demand = clone $this;
140  $demand->firstResult = ‪$firstResult;
141 
142  return $demand;
143  }
144 
145  public function ‪withMaxResults(int ‪$maxResults): self
146  {
147  $demand = clone $this;
148  $demand->maxResults = ‪$maxResults;
149 
150  return $demand;
151  }
152 
153  public function ‪addSearchField(string $tableName, string $field): self
154  {
155  $demand = clone $this;
156  $demand->searchFields[$tableName] = $field;
157 
158  return $demand;
159  }
160 
161  public function ‪addOrdering(string $tableName, string $fieldName, string $direction = 'ASC'): self
162  {
163  $demand = clone $this;
164  $demand->orderings[] = [$tableName, $fieldName, $direction];
165 
166  return $demand;
167  }
168 
169  public function ‪withRecursive(): self
170  {
171  $demand = clone $this;
172  $demand->recursive = true;
173 
174  return $demand;
175  }
176 }
‪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:146
‪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:154
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\withFolder
‪withFolder(Folder $folder)
Definition: FileSearchDemand.php:118
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\withStartResult
‪withStartResult(int $firstResult)
Definition: FileSearchDemand.php:130
‪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:38
‪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:138
‪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:162