[CLEANUP] Adjust code to coding guidelines
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Generic / Mapper / DataMap.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Persistence\Generic\Mapper;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2010-2012 Extbase Team (http://forge.typo3.org/projects/typo3v4-mvc)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
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 * A data map to map a single table configured in $TCA on a domain object.
31 */
32 class DataMap {
33
34 /**
35 * The class name
36 *
37 * @var string
38 */
39 protected $className;
40
41 /**
42 * The table name corresponding to the domain class configured in $TCA
43 *
44 * @var string
45 */
46 protected $tableName;
47
48 /**
49 * The record type stored in the "type" field as configured in $TCA
50 *
51 * @var string
52 */
53 protected $recordType;
54
55 /**
56 * The subclasses of the current class
57 *
58 * @var array
59 */
60 protected $subclasses = array();
61
62 /**
63 * An array of column maps configured in $TCA
64 *
65 * @var array
66 */
67 protected $columnMaps = array();
68
69 /**
70 * @var string
71 */
72 protected $pageIdColumnName;
73
74 /**
75 * @var string
76 */
77 protected $languageIdColumnName;
78
79 /**
80 * @var string
81 */
82 protected $translationOriginColumnName;
83
84 /**
85 * @var string
86 */
87 protected $modificationDateColumnName;
88
89 /**
90 * @var string
91 */
92 protected $creationDateColumnName;
93
94 /**
95 * @var string
96 */
97 protected $creatorColumnName;
98
99 /**
100 * @var string
101 */
102 protected $deletedFlagColumnName;
103
104 /**
105 * @var string
106 */
107 protected $disabledFlagColumnName;
108
109 /**
110 * @var string
111 */
112 protected $startTimeColumnName;
113
114 /**
115 * @var string
116 */
117 protected $endTimeColumnName;
118
119 /**
120 * @var string
121 */
122 protected $frontendUserGroupColumnName;
123
124 /**
125 * @var string
126 */
127 protected $recordTypeColumnName;
128
129 /**
130 * @var bool
131 */
132 protected $isStatic = FALSE;
133
134 /**
135 * @var bool
136 */
137 protected $rootLevel = FALSE;
138
139 /**
140 * Constructs this DataMap
141 *
142 * @param string $className The class name
143 * @param string $tableName The table name
144 * @param string $recordType The record type
145 * @param array $subclasses The subclasses
146 */
147 public function __construct($className, $tableName, $recordType = NULL, array $subclasses = array()) {
148 $this->setClassName($className);
149 $this->setTableName($tableName);
150 $this->setRecordType($recordType);
151 $this->setSubclasses($subclasses);
152 }
153
154 /**
155 * Sets the name of the class the colum map represents
156 *
157 * @param $className
158 * @return void
159 */
160 public function setClassName($className) {
161 $this->className = $className;
162 }
163
164 /**
165 * Returns the name of the class the column map represents
166 *
167 * @return string The class name
168 */
169 public function getClassName() {
170 return $this->className;
171 }
172
173 /**
174 * Sets the name of the table the colum map represents
175 *
176 * @param $tableName
177 * @return void
178 */
179 public function setTableName($tableName) {
180 $this->tableName = $tableName;
181 }
182
183 /**
184 * Returns the name of the table the column map represents
185 *
186 * @return string The table name
187 */
188 public function getTableName() {
189 return $this->tableName;
190 }
191
192 /**
193 * Sets the record type
194 *
195 * @param string $recordType The record type
196 * @return void
197 */
198 public function setRecordType($recordType) {
199 $this->recordType = $recordType;
200 }
201
202 /**
203 * Returns the record type
204 *
205 * @return string The record type
206 */
207 public function getRecordType() {
208 return $this->recordType;
209 }
210
211 /**
212 * Sets the subclasses
213 *
214 * @param array $subclasses An array of subclasses
215 * @return void
216 */
217 public function setSubclasses(array $subclasses) {
218 $this->subclasses = $subclasses;
219 }
220
221 /**
222 * Returns the subclasses
223 *
224 * @return array The subclasses
225 */
226 public function getSubclasses() {
227 return $this->subclasses;
228 }
229
230 /**
231 * Adds a given column map to the data map.
232 *
233 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap $columnMap The column map
234 * @return void
235 */
236 public function addColumnMap(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap $columnMap) {
237 $this->columnMaps[$columnMap->getPropertyName()] = $columnMap;
238 }
239
240 /**
241 * Returns the column map corresponding to the given property name.
242 *
243 * @param string $propertyName
244 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap|NULL The column map or NULL if no corresponding column map was found.
245 */
246 public function getColumnMap($propertyName) {
247 return $this->columnMaps[$propertyName];
248 }
249
250 /**
251 * Returns TRUE if the property is persistable (configured in $TCA)
252 *
253 * @param string $propertyName The property name
254 * @return boolean TRUE if the property is persistable (configured in $TCA)
255 */
256 public function isPersistableProperty($propertyName) {
257 return isset($this->columnMaps[$propertyName]);
258 }
259
260 /**
261 * Sets the name of a column holding the page id
262 *
263 * @param string $pageIdColumnName The field name
264 * @return void
265 */
266 public function setPageIdColumnName($pageIdColumnName) {
267 $this->pageIdColumnName = $pageIdColumnName;
268 }
269
270 /**
271 * Sets the name of a column holding the page id
272 *
273 * @return string The field name
274 */
275 public function getPageIdColumnName() {
276 return $this->pageIdColumnName;
277 }
278
279 /**
280 * Sets the name of a column holding the language id of the record
281 *
282 * @param string $languageIdColumnName The field name
283 * @return void
284 */
285 public function setLanguageIdColumnName($languageIdColumnName) {
286 $this->languageIdColumnName = $languageIdColumnName;
287 }
288
289 /**
290 * Returns the name of a column holding the language id of the record.
291 *
292 * @return string The field name
293 */
294 public function getLanguageIdColumnName() {
295 return $this->languageIdColumnName;
296 }
297
298 /**
299 * Sets the name of a column holding the the uid of the record which this record is a translation of.
300 *
301 * @param string $translationOriginColumnName The field name
302 * @return void
303 */
304 public function setTranslationOriginColumnName($translationOriginColumnName) {
305 $this->translationOriginColumnName = $translationOriginColumnName;
306 }
307
308 /**
309 * Returns the name of a column holding the the uid of the record which this record is a translation of.
310 *
311 * @return string The field name
312 */
313 public function getTranslationOriginColumnName() {
314 return $this->translationOriginColumnName;
315 }
316
317 /**
318 * Sets the name of a column holding the timestamp the record was modified
319 *
320 * @param string $modificationDateColumnName The field name
321 * @return void
322 */
323 public function setModificationDateColumnName($modificationDateColumnName) {
324 $this->modificationDateColumnName = $modificationDateColumnName;
325 }
326
327 /**
328 * Returns the name of a column holding the timestamp the record was modified
329 *
330 * @return string The field name
331 */
332 public function getModificationDateColumnName() {
333 return $this->modificationDateColumnName;
334 }
335
336 /**
337 * Sets the name of a column holding the creation date timestamp
338 *
339 * @param string $creationDateColumnName The field name
340 * @return void
341 */
342 public function setCreationDateColumnName($creationDateColumnName) {
343 $this->creationDateColumnName = $creationDateColumnName;
344 }
345
346 /**
347 * Returns the name of a column holding the creation date timestamp
348 *
349 * @return string The field name
350 */
351 public function getCreationDateColumnName() {
352 return $this->creationDateColumnName;
353 }
354
355 /**
356 * Sets the name of a column holding the uid of the back-end user who created this record
357 *
358 * @param string $creatorColumnName The field name
359 * @return void
360 */
361 public function setCreatorColumnName($creatorColumnName) {
362 $this->creatorColumnName = $creatorColumnName;
363 }
364
365 /**
366 * Returns the name of a column holding the uid of the back-end user who created this record
367 *
368 * @return string The field name
369 */
370 public function getCreatorColumnName() {
371 return $this->creatorColumnName;
372 }
373
374 /**
375 * Sets the name of a column indicating the 'deleted' state of the row
376 *
377 * @param string $deletedFlagColumnName The field name
378 * @return void
379 */
380 public function setDeletedFlagColumnName($deletedFlagColumnName) {
381 $this->deletedFlagColumnName = $deletedFlagColumnName;
382 }
383
384 /**
385 * Returns the name of a column indicating the 'deleted' state of the row
386 *
387 * @return string The field name
388 */
389 public function getDeletedFlagColumnName() {
390 return $this->deletedFlagColumnName;
391 }
392
393 /**
394 * Sets the name of a column indicating the 'hidden' state of the row
395 *
396 * @param string $disabledFlagColumnName The field name
397 * @return void
398 */
399 public function setDisabledFlagColumnName($disabledFlagColumnName) {
400 $this->disabledFlagColumnName = $disabledFlagColumnName;
401 }
402
403 /**
404 * Returns the name of a column indicating the 'hidden' state of the row
405 *
406 * @return string The field name
407 */
408 public function getDisabledFlagColumnName() {
409 return $this->disabledFlagColumnName;
410 }
411
412 /**
413 * Sets the name of a column holding the timestamp the record should not displayed before
414 *
415 * @param string $startTimeColumnName The field name
416 * @return void
417 */
418 public function setStartTimeColumnName($startTimeColumnName) {
419 $this->startTimeColumnName = $startTimeColumnName;
420 }
421
422 /**
423 * Returns the name of a column holding the timestamp the record should not displayed before
424 *
425 * @return string The field name
426 */
427 public function getStartTimeColumnName() {
428 return $this->startTimeColumnName;
429 }
430
431 /**
432 * Sets the name of a column holding the timestamp the record should not displayed afterwards
433 *
434 * @param string $endTimeColumnName The field name
435 * @return void
436 */
437 public function setEndTimeColumnName($endTimeColumnName) {
438 $this->endTimeColumnName = $endTimeColumnName;
439 }
440
441 /**
442 * Returns the name of a column holding the timestamp the record should not displayed afterwards
443 *
444 * @return string The field name
445 */
446 public function getEndTimeColumnName() {
447 return $this->endTimeColumnName;
448 }
449
450 /**
451 * Sets the name of a column holding the uid of the front-end user group which is allowed to edit this record
452 *
453 * @param string $frontendUserGroupColumnName The field name
454 * @return void
455 */
456 public function setFrontEndUserGroupColumnName($frontendUserGroupColumnName) {
457 $this->frontendUserGroupColumnName = $frontendUserGroupColumnName;
458 }
459
460 /**
461 * Returns the name of a column holding the uid of the front-end user group which is allowed to edit this record
462 *
463 * @return string The field name
464 */
465 public function getFrontEndUserGroupColumnName() {
466 return $this->frontendUserGroupColumnName;
467 }
468
469 /**
470 * Sets the name of a column holding the record type
471 *
472 * @param string $recordTypeColumnName The field name
473 * @return void
474 */
475 public function setRecordTypeColumnName($recordTypeColumnName) {
476 $this->recordTypeColumnName = $recordTypeColumnName;
477 }
478
479 /**
480 * Sets the name of a column holding the record type
481 *
482 * @return string The field name
483 */
484 public function getRecordTypeColumnName() {
485 return $this->recordTypeColumnName;
486 }
487
488 /**
489 * @param boolean $isStatic
490 */
491 public function setIsStatic($isStatic) {
492 $this->isStatic = $isStatic;
493 }
494
495 /**
496 * @return boolean
497 */
498 public function getIsStatic() {
499 return $this->isStatic;
500 }
501
502 /**
503 * @param boolean $rootLevel
504 */
505 public function setRootLevel($rootLevel) {
506 $this->rootLevel = $rootLevel;
507 }
508
509 /**
510 * @return boolean
511 */
512 public function getRootLevel() {
513 return $this->rootLevel;
514 }
515 }
516
517 ?>