|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de> 00006 * All rights reserved 00007 * 00008 * This class is a backport of the corresponding class of FLOW3. 00009 * All credits go to the v5 team. 00010 * 00011 * This script is part of the TYPO3 project. The TYPO3 project is 00012 * free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU General Public License as published by 00014 * the Free Software Foundation; either version 2 of the License, or 00015 * (at your option) any later version. 00016 * 00017 * The GNU General Public License can be found at 00018 * http://www.gnu.org/copyleft/gpl.html. 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 00028 /** 00029 * The property types supported by the JCR standard. 00030 * 00031 * The STRING property type is used to store strings. 00032 * BINARY properties are used to store binary data. 00033 * The LONG property type is used to store integers. 00034 * The DECIMAL property type is used to store precise decimal numbers. 00035 * The DOUBLE property type is used to store floating point numbers. 00036 * The DATE property type is used to store time and date information. See 4.2.6.1 Date in the specification. 00037 * The BOOLEAN property type is used to store boolean values. 00038 * A NAME is a pairing of a namespace and a local name. When read, the namespace is mapped to the current prefix. See 4.2.6.2 Name in the specification. 00039 * A PATH property is an ordered list of path elements. A path element is a NAME with an optional index. When read, the NAMEs within the path are mapped to their current prefix. A path may be absolute or relative. See 4.2.6.3 Path in the specification. 00040 * A REFERENCE property stores the identifier of a referenceable node (one having type mix:referenceable), which must exist within the same workspace or session as the REFERENCE property. A REFERENCE property enforces this referential integrity by preventing (in level 2 implementations) the removal of its target node. See 4.2.6.4 Reference in the specification. 00041 * A WEAKREFERENCE property stores the identifier of a referenceable node (one having type mix:referenceable). A WEAKREFERENCE property does not enforce referential integrity. See 4.2.6.5 Weak Reference in the specification. 00042 * A URI property is identical to STRING property except that it only accepts values that conform to the syntax of a URI-reference as defined in RFC 3986. See also 4.2.6.6 URI in the specification. 00043 * UNDEFINED can be used within a property definition (see 4.7.5 Property Definitions) to specify that the property in question may be of any type. However, it cannot be the actual type of any property instance. For example it will never be returned by Property.getType() and (in level 2 implementations) it cannot be assigned as the type when creating a new property. 00044 * 00045 * @package Extbase 00046 * @subpackage Persistence 00047 * @version $Id: PropertyType.php 1729 2009-11-25 21:37:20Z stucki $ 00048 */ 00049 final class Tx_Extbase_Persistence_PropertyType { 00050 00051 /** 00052 * This constant can be used within a property definition to specify that 00053 * the property in question may be of any type. 00054 * However, it cannot be the actual type of any property instance. For 00055 * example, it will never be returned by Property#getType and it cannot be 00056 * assigned as the type when creating a new property. 00057 */ 00058 const UNDEFINED = 0; 00059 00060 /** 00061 * The STRING property type is used to store strings. 00062 */ 00063 const STRING = 1; 00064 00065 /** 00066 * BINARY properties are used to store binary data. 00067 */ 00068 const BINARY = 2; 00069 00070 /** 00071 * The LONG property type is used to store integers. 00072 */ 00073 const LONG = 3; 00074 00075 /** 00076 * The DOUBLE property type is used to store floating point numbers. 00077 */ 00078 const DOUBLE = 4; 00079 00080 /** 00081 * The DATE property type is used to store time and date information. 00082 */ 00083 const DATE = 5; 00084 00085 /** 00086 * The BOOLEAN property type is used to store boolean values. 00087 */ 00088 const BOOLEAN = 6; 00089 00090 /** 00091 * A NAME is a pairing of a namespace and a local name. When read, the 00092 * namespace is mapped to the current prefix. 00093 * 00094 * WE DO NOT USE THIS IN EXTBASE! 00095 */ 00096 const NAME = 7; 00097 00098 /** 00099 * A PATH property is an ordered list of path elements. A path element is a 00100 * NAME with an optional index. When read, the NAMEs within the path are 00101 * mapped to their current prefix. A path may be absolute or relative. 00102 * 00103 * WE DO NOT USE THIS IN EXTBASE! 00104 */ 00105 const PATH = 8; 00106 00107 /** 00108 * A REFERENCE property stores the identifier of a referenceable node (one 00109 * having type mix:referenceable), which must exist within the same 00110 * workspace or session as the REFERENCE property. A REFERENCE property 00111 * enforces this referential integrity by preventing the removal of its 00112 * target node. 00113 */ 00114 const REFERENCE = 9; 00115 00116 /** 00117 * A WEAKREFERENCE property stores the identifier of a referenceable node 00118 * (one having type mix:referenceable). A WEAKREFERENCE property does not 00119 * enforce referential integrity. 00120 * 00121 * WE DO NOT USE THIS IN EXTBASE! 00122 */ 00123 const WEAKREFERENCE = 10; 00124 00125 /** 00126 * A URI property is identical to STRING property except that it only 00127 * accepts values that conform to the syntax of a URI-reference as defined 00128 * in RFC 3986. 00129 * 00130 * WE DO NOT USE THIS IN EXTBASE! 00131 */ 00132 const URI = 11; 00133 00134 /** 00135 * The DECIMAL property type is used to store precise decimal numbers. 00136 * 00137 * WE DO NOT USE THIS IN EXTBASE! 00138 */ 00139 const DECIMAL = 12; 00140 00141 /** 00142 * The INTEGER property type is used to store precise decimal numbers. 00143 * 00144 * WE DO NOT USE THIS IN EXTBASE! 00145 */ 00146 const INTEGER = 13; 00147 00148 /** 00149 * String constant for type name as used in serialization. 00150 */ 00151 const TYPENAME_UNDEFINED = 'undefined'; 00152 00153 /** 00154 * String constant for type name as used in serialization. 00155 */ 00156 const TYPENAME_STRING = 'String'; 00157 00158 /** 00159 * String constant for type name as used in serialization. 00160 */ 00161 const TYPENAME_BINARY = 'Binary'; 00162 00163 /** 00164 * String constant for type name as used in serialization. 00165 */ 00166 const TYPENAME_LONG = 'Long'; 00167 00168 /** 00169 * String constant for type name as used in serialization. 00170 */ 00171 const TYPENAME_DOUBLE = 'Double'; 00172 00173 /** 00174 * String constant for type name as used in serialization. 00175 */ 00176 const TYPENAME_DATE = 'Date'; 00177 00178 /** 00179 * String constant for type name as used in serialization. 00180 */ 00181 const TYPENAME_BOOLEAN = 'Boolean'; 00182 00183 /** 00184 * String constant for type name as used in serialization. 00185 */ 00186 const TYPENAME_NAME = 'Name'; 00187 00188 /** 00189 * String constant for type name as used in serialization. 00190 */ 00191 const TYPENAME_PATH = 'Path'; 00192 00193 /** 00194 * String constant for type name as used in serialization. 00195 */ 00196 const TYPENAME_REFERENCE = 'Reference'; 00197 00198 /** 00199 * String constant for type name as used in serialization. 00200 */ 00201 const TYPENAME_WEAKREFERENCE = 'WeakReference'; 00202 00203 /** 00204 * String constant for type name as used in serialization. 00205 */ 00206 const TYPENAME_URI= 'URI'; 00207 00208 /** 00209 * String constant for type name as used in serialization. 00210 */ 00211 const TYPENAME_DECIMAL = 'Decimal'; 00212 00213 /** 00214 * String constant for type name as used in serialization. 00215 */ 00216 const TYPENAME_INTEGER = 'Integer'; 00217 00218 /** 00219 * Make instantiation impossible... 00220 * 00221 * @return void 00222 */ 00223 private function __construct() {} 00224 00225 /** 00226 * Returns the name of the specified type, as used in serialization. 00227 * 00228 * @param integer $type type the property type 00229 * @return string name of the specified type 00230 */ 00231 static public function nameFromValue($type) { 00232 switch (intval($type)) { 00233 case self::UNDEFINED : 00234 return self::TYPENAME_UNDEFINED; 00235 break; 00236 case self::STRING : 00237 return self::TYPENAME_STRING; 00238 break; 00239 case self::BINARY : 00240 return self::TYPENAME_BINARY; 00241 break; 00242 case self::BOOLEAN : 00243 return self::TYPENAME_BOOLEAN; 00244 break; 00245 case self::LONG : 00246 return self::TYPENAME_LONG; 00247 break; 00248 case self::DOUBLE : 00249 return self::TYPENAME_DOUBLE; 00250 break; 00251 case self::DECIMAL : 00252 return self::TYPENAME_DECIMAL; 00253 break; 00254 case self::INTEGER : 00255 return self::TYPENAME_INTEGER; 00256 break; 00257 case self::DATE : 00258 return self::TYPENAME_DATE; 00259 break; 00260 case self::NAME : 00261 return self::TYPENAME_NAME; 00262 break; 00263 case self::PATH : 00264 return self::TYPENAME_PATH; 00265 break; 00266 case self::REFERENCE : 00267 return self::TYPENAME_REFERENCE; 00268 break; 00269 case self::WEAKREFERENCE : 00270 return self::TYPENAME_WEAKREFERENCE; 00271 break; 00272 case self::URI : 00273 return self::TYPENAME_URI; 00274 break; 00275 } 00276 } 00277 00278 00279 /** 00280 * Returns the numeric constant value of the type with the specified name. 00281 * 00282 * @param string $name The name of the property type 00283 * @return int The numeric constant value 00284 */ 00285 static public function valueFromName($name) { 00286 switch ($name) { 00287 case self::TYPENAME_UNDEFINED : 00288 return self::UNDEFINED; 00289 break; 00290 case self::TYPENAME_STRING : 00291 return self::STRING; 00292 break; 00293 case self::TYPENAME_BINARY : 00294 return self::BINARY; 00295 break; 00296 case self::TYPENAME_LONG : 00297 return self::LONG; 00298 break; 00299 case self::TYPENAME_DOUBLE : 00300 return self::DOUBLE; 00301 break; 00302 case self::TYPENAME_DECIMAL : 00303 return self::DECIMAL; 00304 break; 00305 case self::TYPENAME_INTEGER : 00306 return self::INTEGER; 00307 break; 00308 case self::TYPENAME_DATE : 00309 return self::DATE; 00310 break; 00311 case self::TYPENAME_BOOLEAN : 00312 return self::BOOLEAN; 00313 break; 00314 case self::TYPENAME_NAME : 00315 return self::NAME; 00316 break; 00317 case self::TYPENAME_PATH : 00318 return self::PATH; 00319 break; 00320 case self::TYPENAME_REFERENCE : 00321 return self::REFERENCE; 00322 break; 00323 case self::TYPENAME_WEAKREFERENCE : 00324 return self::WEAKREFERENCE; 00325 break; 00326 case self::TYPENAME_URI : 00327 return self::URI; 00328 break; 00329 } 00330 } 00331 00332 /** 00333 * Returns the numeric constant value of the type for the given PHP type 00334 * name as returned by gettype(). 00335 * 00336 * @param string $type 00337 * @return integer 00338 */ 00339 static public function valueFromType($type) { 00340 switch (strtolower($type)) { 00341 case 'string': 00342 return Tx_Extbase_Persistence_PropertyType::STRING; 00343 break; 00344 case 'boolean': 00345 return Tx_Extbase_Persistence_PropertyType::BOOLEAN; 00346 break; 00347 case 'integer': 00348 return Tx_Extbase_Persistence_PropertyType::LONG; 00349 break; 00350 case 'float': 00351 case 'double': 00352 return Tx_Extbase_Persistence_PropertyType::DOUBLE; 00353 break; 00354 case 'integer': 00355 case 'int': 00356 return Tx_Extbase_Persistence_PropertyType::INTEGER; 00357 break; 00358 case 'datetime': 00359 return Tx_Extbase_Persistence_PropertyType::DATE; 00360 break; 00361 default: 00362 return Tx_Extbase_Persistence_PropertyType::UNDEFINED; 00363 } 00364 } 00365 } 00366 00367 ?>
1.8.0