[CLEANUP] General code cleanup
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Generic / Typo3QuerySettings.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Persistence\Generic;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
8 * All rights reserved
9 *
10 * This class is a backport of the corresponding class of FLOW3.
11 * All credits go to the v5 team.
12 *
13 * This script is part of the TYPO3 project. The TYPO3 project is
14 * free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * The GNU General Public License can be found at
20 * http://www.gnu.org/copyleft/gpl.html.
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * Query settings. This class is NOT part of the FLOW3 API.
31 * It reflects the settings unique to TYPO3 4.x.
32 *
33 * @package Extbase
34 * @subpackage Persistence
35 * @version $Id$
36 * @api
37 */
38 class Typo3QuerySettings implements \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface {
39
40 /**
41 * Flag if the storage page should be respected for the query.
42 *
43 * @var boolean
44 */
45 protected $respectStoragePage = TRUE;
46
47 /**
48 * the pid(s) of the storage page(s) that should be respected for the query.
49 *
50 * @var array
51 */
52 protected $storagePageIds = array();
53
54 /**
55 * A flag indicating whether all or some enable fields should be ignored. If TRUE, all enable fields are ignored.
56 * If--in addition to this--enableFieldsToBeIgnored is set, only fields specified there are ignored. If FALSE, all
57 * enable fields are taken into account, regardless of the enableFieldsToBeIgnored setting.
58 *
59 * @var boolean
60 */
61 protected $ignoreEnableFields = FALSE;
62
63 /**
64 * An array of column names in the enable columns array (array keys in $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']),
65 * to be ignored while building the query statement
66 *
67 * @var array
68 */
69 protected $enableFieldsToBeIgnored = array();
70
71 /**
72 * Flag whether deleted records should be included in the result set.
73 *
74 * @var boolean
75 */
76 protected $includeDeleted = FALSE;
77
78 /**
79 * Flag if the sys_language_uid should be respected (default is TRUE).
80 *
81 * @var boolean
82 */
83 protected $respectSysLanguage = TRUE;
84
85 /**
86 * Flag if the the query result should be returned as raw QueryResult.
87 *
88 * @var boolean
89 */
90 protected $returnRawQueryResult = FALSE;
91
92 /**
93 * As long as we use a feature flag ignoreAllEnableFieldsInBe to determine the default behavior, the
94 * initializeObject is responsible for handling that.
95 */
96 public function initializeObject() {
97 /** @var $objectManager \TYPO3\CMS\Extbase\Object\ObjectManager */
98 $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
99 /** @var $configurationManager \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface */
100 $configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
101 if (TYPO3_MODE === 'BE' && $configurationManager->isFeatureEnabled('ignoreAllEnableFieldsInBe')) {
102 $this->setIgnoreEnableFields(TRUE);
103 }
104 }
105
106 /**
107 * Sets the flag if the storage page should be respected for the query.
108 *
109 * @param boolean $respectStoragePage If TRUE the storage page ID will be determined and the statement will be extended accordingly.
110 * @return \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface (fluent interface)
111 * @api
112 */
113 public function setRespectStoragePage($respectStoragePage) {
114 $this->respectStoragePage = $respectStoragePage;
115 return $this;
116 }
117
118 /**
119 * Returns the state, if the storage page should be respected for the query.
120 *
121 * @return boolean TRUE, if the storage page should be respected; otherwise FALSE.
122 */
123 public function getRespectStoragePage() {
124 return $this->respectStoragePage;
125 }
126
127 /**
128 * Sets the pid(s) of the storage page(s) that should be respected for the query.
129 *
130 * @param array $storagePageIds If TRUE the storage page ID will be determined and the statement will be extended accordingly.
131 * @return \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface instance of $this to allow method chaining
132 * @api
133 */
134 public function setStoragePageIds(array $storagePageIds) {
135 $this->storagePageIds = $storagePageIds;
136 }
137
138 /**
139 * Returns the pid(s) of the storage page(s) that should be respected for the query.
140 *
141 * @return array list of integers that each represent a storage page id
142 */
143 public function getStoragePageIds() {
144 return $this->storagePageIds;
145 }
146
147 /**
148 * Sets the flag if a and language overlay should be performed.
149 *
150 * @param boolean $respectSysLanguage TRUE if a and language overlay should be performed.
151 * @return \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface (fluent interface)
152 * @api
153 */
154 public function setRespectSysLanguage($respectSysLanguage) {
155 $this->respectSysLanguage = $respectSysLanguage;
156 return $this;
157 }
158
159 /**
160 * Returns the state, if a and language overlay should be performed.
161 *
162 * @return boolean TRUE, if a and language overlay should be performed; otherwise FALSE.
163 */
164 public function getRespectSysLanguage() {
165 return $this->respectSysLanguage;
166 }
167
168 /**
169 * Sets the flag if the visibility in the frontend should be respected.
170 *
171 * @param boolean $respectEnableFields TRUE if the visibility in the frontend should be respected. If TRUE, the "enable fields" of TYPO3 will be added to the query statement.
172 * @return \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface (fluent interface)
173 * @deprecated since Extbase 6.0, will be removed in Extbase 6.2. Use setIgnoreEnableFields() and setEnableFieldsToBeIgnored() instead.
174 * @see setIgnoreEnableFields()
175 * @see setEnableFieldsToBeIgnored()
176 * @api
177 */
178 public function setRespectEnableFields($respectEnableFields) {
179 \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
180 $this->setIgnoreEnableFields(!$respectEnableFields);
181 $this->setIncludeDeleted(!$respectEnableFields);
182 return $this;
183 }
184
185 /**
186 * Returns the state, if the visibility settings for the frontend should be respected for the query.
187 *
188 * @return boolean TRUE, if the visibility settings for the frontend should should be respected; otherwise FALSE.
189 * @deprecated since Extbase 6.0, will be removed in Extbase 6.2. Use getIgnoreEnableFields() and getEnableFieldsToBeIgnored() instead.
190 * @see getIgnoreEnableFields()
191 * @see getEnableFieldsToBeIgnored()
192 */
193 public function getRespectEnableFields() {
194 \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
195 return !($this->getIgnoreEnableFields() && $this->getIncludeDeleted());
196 }
197
198 /**
199 * Sets a flag indicating whether all or some enable fields should be ignored. If TRUE, all enable fields are ignored.
200 * If--in addition to this--enableFieldsToBeIgnored is set, only fields specified there are ignored. If FALSE, all
201 * enable fields are taken into account, regardless of the enableFieldsToBeIgnored setting.
202 *
203 * @param boolean $ignoreEnableFields
204 * @see setEnableFieldsToBeIgnored()
205 * @api
206 */
207 public function setIgnoreEnableFields($ignoreEnableFields) {
208 $this->ignoreEnableFields = $ignoreEnableFields;
209 }
210
211 /**
212 * The returned value indicates whether all or some enable fields should be ignored.
213 *
214 * If TRUE, all enable fields are ignored. If--in addition to this--enableFieldsToBeIgnored is set, only fields specified there are ignored.
215 * If FALSE, all enable fields are taken into account, regardless of the enableFieldsToBeIgnored setting.
216 *
217 * @return boolean
218 * @see getEnableFieldsToBeIgnored()
219 */
220 public function getIgnoreEnableFields() {
221 return $this->ignoreEnableFields;
222 }
223
224 /**
225 * An array of column names in the enable columns array (array keys in $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']),
226 * to be ignored while building the query statement. Adding a column name here effectively switches off filtering
227 * by this column. This setting is only taken into account if $this->ignoreEnableFields = TRUE.
228 *
229 * @param array $enableFieldsToBeIgnored
230 * @return void
231 * @see setIgnoreEnableFields()
232 * @api
233 */
234 public function setEnableFieldsToBeIgnored($enableFieldsToBeIgnored) {
235 $this->enableFieldsToBeIgnored = $enableFieldsToBeIgnored;
236 }
237
238 /**
239 * An array of column names in the enable columns array (array keys in $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']),
240 * to be ignored while building the query statement.
241 *
242 * @return array
243 * @see getIgnoreEnableFields()
244 */
245 public function getEnableFieldsToBeIgnored() {
246 return $this->enableFieldsToBeIgnored;
247 }
248
249 /**
250 * Sets the flag if the query should return objects that are deleted.
251 *
252 * @param boolean $includeDeleted
253 * @return void
254 * @api
255 */
256 public function setIncludeDeleted($includeDeleted) {
257 $this->includeDeleted = $includeDeleted;
258 }
259
260 /**
261 * Returns if the query should return objects that are deleted.
262 *
263 * @return boolean
264 */
265 public function getIncludeDeleted() {
266 return $this->includeDeleted;
267 }
268
269 /**
270 * Sets the state, if the QueryResult should be returned unmapped.
271 *
272 * @var boolean $returnRawQueryResult TRUE, if the QueryResult should be returned unmapped; otherwise FALSE.
273 * @return void
274 */
275 public function setReturnRawQueryResult($returnRawQueryResult) {
276 $this->returnRawQueryResult = $returnRawQueryResult;
277 }
278
279 /**
280 * Returns the state, if the QueryResult should be returned unmapped.
281 *
282 * @return boolean TRUE, if the QueryResult should be returned unmapped; otherwise FALSE.
283 */
284 public function getReturnRawQueryResult() {
285 return $this->returnRawQueryResult;
286 }
287
288 }
289
290
291 ?>