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