[TASK] Turn todos into @todo to find them easier
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Generic / Mapper / ColumnMap.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Persistence\Generic\Mapper;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16 /**
17 * A column map to map a column configured in $TCA on a property of a domain object.
18 */
19 class ColumnMap {
20 /**
21 * Constants reflecting the type of relation
22 */
23 const RELATION_NONE = 'RELATION_NONE';
24 const RELATION_HAS_ONE = 'RELATION_HAS_ONE';
25 const RELATION_HAS_MANY = 'RELATION_HAS_MANY';
26 const RELATION_BELONGS_TO_MANY = 'RELATION_BELONGS_TO_MANY';
27 const RELATION_HAS_AND_BELONGS_TO_MANY = 'RELATION_HAS_AND_BELONGS_TO_MANY';
28
29 /**
30 * Constants reflecting how the relation information is stored
31 */
32 const RELATION_PARENT_FOREIGN_KEY = 'RELATION_PARENT_FOREIGN_KEY';
33 const RELATION_CHILD_FOREIGN_KEY = 'RELATION_CHILD_FOREIGN_KEY';
34 const RELATION_PARENT_CSV = 'RELATION_PARENT_CSV';
35 const RELATION_INTERMEDIATE_TABLE = 'RELATION_INTERMEDIATE_TABLE';
36
37 /**
38 * Constants reflecting the loading strategy
39 */
40 const STRATEGY_EAGER = 'eager';
41 const STRATEGY_LAZY_PROXY = 'proxy';
42 const STRATEGY_LAZY_STORAGE = 'storage';
43
44 /**
45 * The property name corresponding to the table name
46 *
47 * @var string
48 */
49 protected $propertyName;
50
51 /**
52 * The column name
53 *
54 * @var string
55 */
56 protected $columnName;
57
58 /**
59 * The type of relation
60 *
61 * @var string
62 */
63 protected $typeOfRelation;
64
65 /**
66 * The name of the child's class
67 *
68 * @var string
69 */
70 protected $childClassName;
71
72 /**
73 * The name of the child's table
74 *
75 * @var string
76 */
77 protected $childTableName;
78
79 /**
80 * The where clause to narrow down the selected child records
81 *
82 * @var string
83 */
84 protected $childTableWhereStatement;
85
86 /**
87 * The name of the field the results from the child's table are sorted by
88 *
89 * @var string
90 */
91 protected $childSortByFieldName;
92
93 /**
94 * The name of the relation table
95 *
96 * @var string
97 */
98 protected $relationTableName;
99
100 /**
101 * The name of the column of the relation table holding the page id
102 *
103 * @var string
104 */
105 protected $relationTablePageIdColumnName;
106
107 /**
108 * An array of field => value pairs to both insert and match against when writing/reading MM relations
109 *
110 * @var array
111 */
112 protected $relationTableMatchFields;
113
114 /**
115 * Array of field=>value pairs to insert when writing new MM relations
116 *
117 * @var array
118 */
119 protected $relationTableInsertFields;
120
121 /**
122 * The where clause to narrow down the selected relation table records
123 *
124 * @var string
125 */
126 protected $relationTableWhereStatement;
127
128 /**
129 * The name of the field holding the parents key
130 *
131 * @var string
132 */
133 protected $parentKeyFieldName;
134
135 /**
136 * The name of the field holding the name of the table of the parent's records
137 *
138 * @var string
139 */
140 protected $parentTableFieldName;
141
142 /**
143 * The name of the field holding the children key
144 *
145 * @var string
146 */
147 protected $childKeyFieldName;
148
149 /**
150 * Alternative format for storing DataTime formats
151 * (instead of using unix-time stamps). Allowed values
152 * are 'date' and 'datetime'
153 *
154 * @var string
155 */
156 protected $dateTimeStorageFormat;
157
158 /**
159 * @var \TYPO3\CMS\Core\DataHandling\TableColumnType
160 */
161 protected $type;
162
163 /**
164 * @var \TYPO3\CMS\Core\DataHandling\TableColumnSubType
165 */
166 protected $internalType;
167
168 /**
169 * Constructs a Column Map
170 *
171 * @param string $columnName The column name
172 * @param string $propertyName The property name
173 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap
174 */
175 public function __construct($columnName, $propertyName) {
176 // @todo Enable aliases (tx_anotherextension_addedcolumn -> theAddedColumn)
177 $this->setColumnName($columnName);
178 $this->setPropertyName($propertyName);
179 }
180
181 /**
182 * @param string $typeOfRelation
183 */
184 public function setTypeOfRelation($typeOfRelation) {
185 $this->typeOfRelation = $typeOfRelation;
186 }
187
188 /**
189 * @return string
190 */
191 public function getTypeOfRelation() {
192 return $this->typeOfRelation;
193 }
194
195 /**
196 * @param string $propertyName
197 */
198 public function setPropertyName($propertyName) {
199 $this->propertyName = $propertyName;
200 }
201
202 /**
203 * @return string
204 */
205 public function getPropertyName() {
206 return $this->propertyName;
207 }
208
209 /**
210 * @param string $columnName
211 */
212 public function setColumnName($columnName) {
213 $this->columnName = $columnName;
214 }
215
216 /**
217 * @return string
218 */
219 public function getColumnName() {
220 return $this->columnName;
221 }
222
223 /**
224 * @param string $childTableName
225 */
226 public function setChildTableName($childTableName) {
227 $this->childTableName = $childTableName;
228 }
229
230 /**
231 * @return string
232 */
233 public function getChildTableName() {
234 return $this->childTableName;
235 }
236
237 /**
238 * @param string $childTableWhereStatement
239 */
240 public function setChildTableWhereStatement($childTableWhereStatement) {
241 $this->childTableWhereStatement = $childTableWhereStatement;
242 }
243
244 /**
245 * @return string
246 */
247 public function getChildTableWhereStatement() {
248 return $this->childTableWhereStatement;
249 }
250
251 /**
252 * @param string $childSortByFieldName
253 */
254 public function setChildSortByFieldName($childSortByFieldName) {
255 $this->childSortByFieldName = $childSortByFieldName;
256 }
257
258 /**
259 * @return string
260 */
261 public function getChildSortByFieldName() {
262 return $this->childSortByFieldName;
263 }
264
265 /**
266 * @param string $relationTableName
267 */
268 public function setRelationTableName($relationTableName) {
269 $this->relationTableName = $relationTableName;
270 }
271
272 /**
273 * @return string
274 */
275 public function getRelationTableName() {
276 return $this->relationTableName;
277 }
278
279 /**
280 * @param string $relationTablePageIdColumnName
281 */
282 public function setRelationTablePageIdColumnName($relationTablePageIdColumnName) {
283 $this->relationTablePageIdColumnName = $relationTablePageIdColumnName;
284 }
285
286 /**
287 * @return string
288 */
289 public function getRelationTablePageIdColumnName() {
290 return $this->relationTablePageIdColumnName;
291 }
292
293 /**
294 * @param array $relationTableMatchFields
295 */
296 public function setRelationTableMatchFields(array $relationTableMatchFields) {
297 $this->relationTableMatchFields = $relationTableMatchFields;
298 }
299
300 /**
301 * @return array
302 */
303 public function getRelationTableMatchFields() {
304 return $this->relationTableMatchFields;
305 }
306
307 /**
308 * @param array $relationTableInsertFields
309 */
310 public function setRelationTableInsertFields(array $relationTableInsertFields) {
311 $this->relationTableInsertFields = $relationTableInsertFields;
312 }
313
314 /**
315 * @return array
316 */
317 public function getRelationTableInsertFields() {
318 return $this->relationTableInsertFields;
319 }
320
321 /**
322 * @param string $relationTableWhereStatement
323 */
324 public function setRelationTableWhereStatement($relationTableWhereStatement) {
325 $this->relationTableWhereStatement = $relationTableWhereStatement;
326 }
327
328 /**
329 * @return string
330 */
331 public function getRelationTableWhereStatement() {
332 return $this->relationTableWhereStatement;
333 }
334
335 /**
336 * @param string $parentKeyFieldName
337 */
338 public function setParentKeyFieldName($parentKeyFieldName) {
339 $this->parentKeyFieldName = $parentKeyFieldName;
340 }
341
342 /**
343 * @return string
344 */
345 public function getParentKeyFieldName() {
346 return $this->parentKeyFieldName;
347 }
348
349 /**
350 * @param string $parentTableFieldName
351 */
352 public function setParentTableFieldName($parentTableFieldName) {
353 $this->parentTableFieldName = $parentTableFieldName;
354 }
355
356 /**
357 * @return string
358 */
359 public function getParentTableFieldName() {
360 return $this->parentTableFieldName;
361 }
362
363 /**
364 * @param string $childKeyFieldName
365 */
366 public function setChildKeyFieldName($childKeyFieldName) {
367 $this->childKeyFieldName = $childKeyFieldName;
368 }
369
370 /**
371 * @return string
372 */
373 public function getChildKeyFieldName() {
374 return $this->childKeyFieldName;
375 }
376
377 /**
378 * @param string $dateTimeStorageFormat
379 */
380 public function setDateTimeStorageFormat($dateTimeStorageFormat) {
381 $this->dateTimeStorageFormat = $dateTimeStorageFormat;
382 }
383
384 /**
385 * @return string
386 */
387 public function getDateTimeStorageFormat() {
388 return $this->dateTimeStorageFormat;
389 }
390
391 /**
392 * @param \TYPO3\CMS\Core\DataHandling\TableColumnSubType $internalType
393 */
394 public function setInternalType($internalType) {
395 $this->internalType = $internalType;
396 }
397
398 /**
399 * @return \TYPO3\CMS\Core\DataHandling\TableColumnSubType
400 */
401 public function getInternalType() {
402 return $this->internalType;
403 }
404
405 /**
406 * @param \TYPO3\CMS\Core\DataHandling\TableColumnType $type
407 */
408 public function setType($type) {
409 $this->type = $type;
410 }
411
412 /**
413 * @return \TYPO3\CMS\Core\DataHandling\TableColumnType
414 */
415 public function getType() {
416 return $this->type;
417 }
418 }