* renamed TcaMapper to ObjectRelationalMapper
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Mapper / TX_EXTMVC_Persistence_Mapper_ColumnMap.php
1 <?php
2 declare(ENCODING = 'utf-8');
3
4 /* *
5 * This script belongs to the FLOW3 framework. *
6 * *
7 * It is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU Lesser General Public License as published by the *
9 * Free Software Foundation, either version 3 of the License, or (at your *
10 * option) any later version. *
11 * *
12 * This script is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
14 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
15 * General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License along with the script. *
19 * If not, see http://www.gnu.org/licenses/lgpl.html *
20 * *
21 * The TYPO3 project - inspiring people to share! *
22 * */
23
24 /**
25 * A column map to map a column configured in $TCA on a property of a domain object.
26 *
27 * @version $Id:$
28 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
29 */
30 class TX_EXTMVC_Persistence_Mapper_ColumnMap {
31
32 /**
33 * Constants reflecting the type of relation
34 */
35 const RELATION_NONE = 0;
36 const RELATION_HAS_ONE = 1;
37 const RELATION_HAS_MANY = 2;
38 const RELATION_HAS_AND_BELONGS_TO_MANY = 3;
39
40 /**
41 * Constants reflecting the type of value
42 */
43 const TYPE_UNKNOWN = 0;
44 const TYPE_STRING = 1;
45 const TYPE_DATE = 2;
46 const TYPE_INTEGER = 3;
47 const TYPE_FLOAT = 4;
48 const TYPE_BOOLEAN = 5;
49
50 /**
51 * The property name corresponding to the table name
52 *
53 * @var string
54 **/
55 protected $propertyName;
56
57 /**
58 * The column name
59 *
60 * @var string
61 **/
62 protected $columnName;
63
64 /**
65 * The type of relation
66 *
67 * @var int
68 **/
69 protected $typeOfRelation;
70
71 /**
72 * The type of value
73 *
74 * @var int
75 **/
76 protected $typeOfValue;
77
78 /**
79 * The name of the child's class
80 *
81 * @var string
82 **/
83 protected $childClassName;
84
85 /**
86 * The name of the child's table
87 *
88 * @var string
89 **/
90 protected $childTableName;
91
92 /**
93 * The where clause to narrow down the selected child records
94 *
95 * @var string
96 **/
97 protected $childTableWhere;
98
99 /**
100 * The name of the field the results from the child's table are sorted by
101 *
102 * @var string
103 **/
104 protected $childSortByFieldName;
105
106 /**
107 * The name of the relation table
108 *
109 * @var string
110 **/
111 protected $relationTableName;
112
113 /**
114 * The name of the field holding the parents key
115 *
116 * @var string
117 **/
118 protected $parentKeyFieldName;
119
120 /**
121 * The name of the field holding the name of the table of the parent's records
122 *
123 * @var string
124 **/
125 protected $parentTableFieldName;
126
127 public function __construct($columnName) {
128 $this->setColumnName($columnName);
129 $this->setPropertyName(TX_EXTMVC_Utility_Strings::underscoredToLowerCamelCase($columnName));
130 }
131
132 public function setTypeOfRelation($typeOfRelation) {
133 switch ($typeOfRelation) {
134 case self::TYPE_UNKNOWN;
135 case self::TYPE_STRING;
136 case self::TYPE_DATE;
137 case self::TYPE_INTEGER;
138 case self::TYPE_FLOAT;
139 case self::TYPE_BOOLEAN;
140 $this->typeOfRelation = $typeOfRelation;
141 break;
142 default:
143 $this->typeOfRelation = NULL;
144 break;
145 }
146 }
147
148 public function getTypeOfRelation() {
149 return $this->typeOfRelation;
150 }
151
152 public function setTypeOfValue($typeOfValue) {
153 switch ($typeOfValue) {
154 case self::RELATION_NONE;
155 case self::RELATION_HAS_ONE;
156 case self::RELATION_HAS_MANY;
157 case self::RELATION_HAS_AND_BELONGS_TO_MANY;
158 $this->typeOfValue = $typeOfValue;
159 break;
160 default:
161 $this->typeOfValue = NULL;
162 break;
163 }
164 }
165
166 public function getTypeOfValue() {
167 return $this->typeOfValue;
168 }
169
170 public function setPropertyName($propertyName) {
171 $this->propertyName = $propertyName;
172 }
173
174 public function getPropertyName() {
175 return $this->propertyName;
176 }
177
178 public function setColumnName($columnName) {
179 $this->columnName = $columnName;
180 }
181
182 public function getColumnName() {
183 return $this->columnName;
184 }
185
186 public function setChildClassName($childClassName) {
187 $this->childClassName = $childClassName;
188 }
189
190 public function getChildClassName() {
191 return $this->childClassName;
192 }
193
194 public function setChildTableName($childTableName) {
195 $this->childTableName = $childTableName;
196 }
197
198 public function getChildTableName() {
199 return $this->childTableName;
200 }
201
202 public function setChildTableWhere($childTableWhere) {
203 $this->childTableWhere = $childTableWhere;
204 }
205
206 public function getChildTableWhere() {
207 return $this->childTableWhere;
208 }
209
210 public function setChildSortByFieldName($childSortByFieldName) {
211 $this->childSortByFieldName = $childSortByFieldName;
212 }
213
214 public function getChildSortByFieldName() {
215 return $this->childSortByFieldName;
216 }
217
218 public function setRelationTableName($relationTableName) {
219 $this->relationTableName = $relationTableName;
220 }
221
222 public function getRelationTableName() {
223 return $this->relationTableName;
224 }
225
226 public function setParentKeyFieldName($parentKeyFieldName) {
227 $this->parentKeyFieldName = $parentKeyFieldName;
228 }
229
230 public function getParentKeyFieldName() {
231 return $this->parentKeyFieldName;
232 }
233
234 public function setParentTableFieldName($parentTableFieldName) {
235 $this->parentTableFieldName = $parentTableFieldName;
236 }
237
238 public function getParentTableFieldName() {
239 return $this->parentTableFieldName;
240 }
241
242 }
243 ?>