* added isRelation() method to Column Map
[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::RELATION_NONE;
135 case self::RELATION_HAS_ONE;
136 case self::RELATION_HAS_MANY;
137 case self::RELATION_HAS_AND_BELONGS_TO_MANY;
138 $this->typeOfRelation = $typeOfRelation;
139 break;
140 default:
141 $this->typeOfRelation = NULL;
142 break;
143 }
144 }
145
146 public function isRelation() {
147 return $this->typeOfRelation !== NULL && $this->typeOfRelation !== self::RELATION_NONE;
148 }
149
150 public function getTypeOfRelation() {
151 return $this->typeOfRelation;
152 }
153
154 public function setTypeOfValue($typeOfValue) {
155 switch ($typeOfValue) {
156 case self::TYPE_UNKNOWN;
157 case self::TYPE_STRING;
158 case self::TYPE_DATE;
159 case self::TYPE_INTEGER;
160 case self::TYPE_FLOAT;
161 case self::TYPE_BOOLEAN;
162 $this->typeOfValue = $typeOfValue;
163 break;
164 default:
165 $this->typeOfValue = NULL;
166 break;
167 }
168 }
169
170 public function getTypeOfValue() {
171 return $this->typeOfValue;
172 }
173
174 public function setPropertyName($propertyName) {
175 $this->propertyName = $propertyName;
176 }
177
178 public function getPropertyName() {
179 return $this->propertyName;
180 }
181
182 public function setColumnName($columnName) {
183 $this->columnName = $columnName;
184 }
185
186 public function getColumnName() {
187 return $this->columnName;
188 }
189
190 public function setChildClassName($childClassName) {
191 $this->childClassName = $childClassName;
192 }
193
194 public function getChildClassName() {
195 return $this->childClassName;
196 }
197
198 public function setChildTableName($childTableName) {
199 $this->childTableName = $childTableName;
200 }
201
202 public function getChildTableName() {
203 return $this->childTableName;
204 }
205
206 public function setChildTableWhere($childTableWhere) {
207 $this->childTableWhere = $childTableWhere;
208 }
209
210 public function getChildTableWhere() {
211 return $this->childTableWhere;
212 }
213
214 public function setChildSortByFieldName($childSortByFieldName) {
215 $this->childSortByFieldName = $childSortByFieldName;
216 }
217
218 public function getChildSortByFieldName() {
219 return $this->childSortByFieldName;
220 }
221
222 public function setRelationTableName($relationTableName) {
223 $this->relationTableName = $relationTableName;
224 }
225
226 public function getRelationTableName() {
227 return $this->relationTableName;
228 }
229
230 public function setParentKeyFieldName($parentKeyFieldName) {
231 $this->parentKeyFieldName = $parentKeyFieldName;
232 }
233
234 public function getParentKeyFieldName() {
235 return $this->parentKeyFieldName;
236 }
237
238 public function setParentTableFieldName($parentTableFieldName) {
239 $this->parentTableFieldName = $parentTableFieldName;
240 }
241
242 public function getParentTableFieldName() {
243 return $this->parentTableFieldName;
244 }
245
246 }
247 ?>