TYPO3 CMS  TYPO3_6-2
PropertyType.php
Go to the documentation of this file.
1 <?php
3 
33 class PropertyType {
34 
42  const UNDEFINED = 0;
43 
47  const STRING = 1;
48 
52  const BINARY = 2;
53 
57  const LONG = 3;
58 
62  const DOUBLE = 4;
63 
67  const DATE = 5;
68 
72  const BOOLEAN = 6;
73 
80  const NAME = 7;
81 
89  const PATH = 8;
90 
98  const REFERENCE = 9;
99 
107  const WEAKREFERENCE = 10;
108 
116  const URI = 11;
117 
123  const DECIMAL = 12;
124 
130  const INTEGER = 13;
131 
135  const TYPENAME_UNDEFINED = 'undefined';
136 
140  const TYPENAME_STRING = 'String';
141 
145  const TYPENAME_BINARY = 'Binary';
146 
150  const TYPENAME_LONG = 'Long';
151 
155  const TYPENAME_DOUBLE = 'Double';
156 
160  const TYPENAME_DATE = 'Date';
161 
165  const TYPENAME_BOOLEAN = 'Boolean';
166 
170  const TYPENAME_NAME = 'Name';
171 
175  const TYPENAME_PATH = 'Path';
176 
180  const TYPENAME_REFERENCE = 'Reference';
181 
185  const TYPENAME_WEAKREFERENCE = 'WeakReference';
186 
190  const TYPENAME_URI = 'URI';
191 
195  const TYPENAME_DECIMAL = 'Decimal';
196 
200  const TYPENAME_INTEGER = 'Integer';
201 
205  private function __construct() {
206  }
207 
214  static public function nameFromValue($type) {
215  switch ((int)$type) {
216  case self::STRING:
217  $name = self::TYPENAME_STRING;
218  break;
219  case self::BINARY:
220  $name = self::TYPENAME_BINARY;
221  break;
222  case self::BOOLEAN:
223  $name = self::TYPENAME_BOOLEAN;
224  break;
225  case self::LONG:
226  $name = self::TYPENAME_LONG;
227  break;
228  case self::DOUBLE:
229  $name = self::TYPENAME_DOUBLE;
230  break;
231  case self::DECIMAL:
232  $name = self::TYPENAME_DECIMAL;
233  break;
234  case self::INTEGER:
235  $name = self::TYPENAME_INTEGER;
236  break;
237  case self::DATE:
238  $name = self::TYPENAME_DATE;
239  break;
240  case self::NAME:
241  $name = self::TYPENAME_NAME;
242  break;
243  case self::PATH:
244  $name = self::TYPENAME_PATH;
245  break;
246  case self::REFERENCE:
247  $name = self::TYPENAME_REFERENCE;
248  break;
249  case self::WEAKREFERENCE:
250  $name = self::TYPENAME_WEAKREFERENCE;
251  break;
252  case self::URI:
253  $name = self::TYPENAME_URI;
254  break;
255  default:
256  // case self::UNDEFINED:
257  $name = self::TYPENAME_UNDEFINED;
258  }
259 
260  return $name;
261  }
262 
269  static public function valueFromName($name) {
270  switch ($name) {
271  case self::TYPENAME_STRING:
272  $value = self::STRING;
273  break;
274  case self::TYPENAME_BINARY:
275  $value = self::BINARY;
276  break;
277  case self::TYPENAME_LONG:
278  $value = self::LONG;
279  break;
280  case self::TYPENAME_DOUBLE:
281  $value = self::DOUBLE;
282  break;
283  case self::TYPENAME_DECIMAL:
284  $value = self::DECIMAL;
285  break;
286  case self::TYPENAME_INTEGER:
287  $value = self::INTEGER;
288  break;
289  case self::TYPENAME_DATE:
290  $value = self::DATE;
291  break;
292  case self::TYPENAME_BOOLEAN:
293  $value = self::BOOLEAN;
294  break;
295  case self::TYPENAME_NAME:
296  $value = self::NAME;
297  break;
298  case self::TYPENAME_PATH:
299  $value = self::PATH;
300  break;
301  case self::TYPENAME_REFERENCE:
302  $value = self::REFERENCE;
303  break;
304  case self::TYPENAME_WEAKREFERENCE:
305  $value = self::WEAKREFERENCE;
306  break;
307  case self::TYPENAME_URI:
308  $value = self::URI;
309  break;
310  default:
311  // case self::TYPENAME_UNDEFINED:
312  $value = self::UNDEFINED;
313  }
314 
315  return $value;
316  }
317 
325  static public function valueFromType($type) {
326  switch (strtolower($type)) {
327  case 'string':
329  break;
330  case 'boolean':
332  break;
333  case 'integer':
335  break;
336  case 'float':
337 
338  case 'double':
340  break;
341  case 'int':
343  break;
344  case 'datetime':
346  break;
347  default:
349  }
350 
351  return $value;
352  }
353 }