TYPO3 CMS  TYPO3_8-7
PropertyType.php
Go to the documentation of this file.
1 <?php
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 
35 {
43  const UNDEFINED = 0;
44 
48  const STRING = 1;
49 
53  const BINARY = 2;
54 
58  const LONG = 3;
59 
63  const DOUBLE = 4;
64 
68  const DATE = 5;
69 
73  const BOOLEAN = 6;
74 
81  const NAME = 7;
82 
90  const PATH = 8;
91 
99  const REFERENCE = 9;
100 
108  const WEAKREFERENCE = 10;
109 
117  const URI = 11;
118 
124  const DECIMAL = 12;
125 
131  const INTEGER = 13;
132 
136  const TYPENAME_UNDEFINED = 'undefined';
137 
141  const TYPENAME_STRING = 'String';
142 
146  const TYPENAME_BINARY = 'Binary';
147 
151  const TYPENAME_LONG = 'Long';
152 
156  const TYPENAME_DOUBLE = 'Double';
157 
161  const TYPENAME_DATE = 'Date';
162 
166  const TYPENAME_BOOLEAN = 'Boolean';
167 
171  const TYPENAME_NAME = 'Name';
172 
176  const TYPENAME_PATH = 'Path';
177 
181  const TYPENAME_REFERENCE = 'Reference';
182 
186  const TYPENAME_WEAKREFERENCE = 'WeakReference';
187 
191  const TYPENAME_URI = 'URI';
192 
196  const TYPENAME_DECIMAL = 'Decimal';
197 
201  const TYPENAME_INTEGER = 'Integer';
202 
206  private function __construct()
207  {
208  }
209 
216  public static function nameFromValue($type)
217  {
218  switch ((int)$type) {
219  case self::STRING:
220  $name = self::TYPENAME_STRING;
221  break;
222  case self::BINARY:
223  $name = self::TYPENAME_BINARY;
224  break;
225  case self::BOOLEAN:
226  $name = self::TYPENAME_BOOLEAN;
227  break;
228  case self::LONG:
229  $name = self::TYPENAME_LONG;
230  break;
231  case self::DOUBLE:
232  $name = self::TYPENAME_DOUBLE;
233  break;
234  case self::DECIMAL:
235  $name = self::TYPENAME_DECIMAL;
236  break;
237  case self::INTEGER:
238  $name = self::TYPENAME_INTEGER;
239  break;
240  case self::DATE:
241  $name = self::TYPENAME_DATE;
242  break;
243  case self::NAME:
244  $name = self::TYPENAME_NAME;
245  break;
246  case self::PATH:
247  $name = self::TYPENAME_PATH;
248  break;
249  case self::REFERENCE:
250  $name = self::TYPENAME_REFERENCE;
251  break;
252  case self::WEAKREFERENCE:
253  $name = self::TYPENAME_WEAKREFERENCE;
254  break;
255  case self::URI:
256  $name = self::TYPENAME_URI;
257  break;
258  default:
259  // case self::UNDEFINED:
260  $name = self::TYPENAME_UNDEFINED;
261  }
262 
263  return $name;
264  }
265 
272  public static function valueFromName($name)
273  {
274  switch ($name) {
275  case self::TYPENAME_STRING:
276  $value = self::STRING;
277  break;
278  case self::TYPENAME_BINARY:
279  $value = self::BINARY;
280  break;
281  case self::TYPENAME_LONG:
282  $value = self::LONG;
283  break;
284  case self::TYPENAME_DOUBLE:
285  $value = self::DOUBLE;
286  break;
287  case self::TYPENAME_DECIMAL:
288  $value = self::DECIMAL;
289  break;
290  case self::TYPENAME_INTEGER:
291  $value = self::INTEGER;
292  break;
293  case self::TYPENAME_DATE:
294  $value = self::DATE;
295  break;
296  case self::TYPENAME_BOOLEAN:
297  $value = self::BOOLEAN;
298  break;
299  case self::TYPENAME_NAME:
300  $value = self::NAME;
301  break;
302  case self::TYPENAME_PATH:
303  $value = self::PATH;
304  break;
305  case self::TYPENAME_REFERENCE:
306  $value = self::REFERENCE;
307  break;
308  case self::TYPENAME_WEAKREFERENCE:
309  $value = self::WEAKREFERENCE;
310  break;
311  case self::TYPENAME_URI:
312  $value = self::URI;
313  break;
314  default:
315  // case self::TYPENAME_UNDEFINED:
316  $value = self::UNDEFINED;
317  }
318 
319  return $value;
320  }
321 
329  public static function valueFromType($type)
330  {
331  switch (strtolower($type)) {
332  case 'string':
334  break;
335  case 'boolean':
337  break;
338  case 'integer':
340  break;
341  case 'float':
342 
343  case 'double':
345  break;
346  case 'int':
348  break;
349  case 'datetime':
351  break;
352  default:
354  }
355 
356  return $value;
357  }
358 }