Changeset 4776 for trunk/lib/Doctrine
- Timestamp:
- 08/16/08 20:40:59 (5 months ago)
- Location:
- trunk/lib/Doctrine
- Files:
-
- 3 added
- 27 modified
-
Access.php (modified) (1 diff)
-
Association.php (modified) (17 diffs)
-
Association/OneToOne.php (modified) (1 diff)
-
ClassMetadata.php (modified) (32 diffs)
-
ClassMetadata/Factory.php (modified) (5 diffs)
-
Collection.php (modified) (38 diffs)
-
CollectionPersister (added)
-
CollectionPersister/Abstract.php (added)
-
CollectionPersister/OneToManyPersister.php (added)
-
Connection/UnitOfWork.php (modified) (6 diffs)
-
DatabasePlatform.php (modified) (2 diffs)
-
DatabasePlatform/MySqlPlatform.php (modified) (1 diff)
-
DatabasePlatform/OraclePlatform.php (modified) (1 diff)
-
Entity.php (modified) (25 diffs)
-
EntityManager.php (modified) (16 diffs)
-
EntityPersister/Abstract.php (modified) (4 diffs)
-
EntityPersister/Standard.php (modified) (2 diffs)
-
EventManager.php (modified) (2 diffs)
-
Exception.php (modified) (1 diff)
-
Hydrator/RecordDriver.php (modified) (1 diff)
-
HydratorNew.php (modified) (2 diffs)
-
MappingException.php (modified) (2 diffs)
-
Query/CacheHandler.php (modified) (2 diffs)
-
Query/Production/Join.php (modified) (2 diffs)
-
Query/Production/PathExpression.php (modified) (1 diff)
-
Query/Production/PathExpressionEndingWithAsterisk.php (modified) (1 diff)
-
Query/Production/RangeVariableDeclaration.php (modified) (3 diffs)
-
Relation.php (modified) (1 diff)
-
Relation/Parser.php (modified) (1 diff)
-
Schema/MsSqlSchemaManager.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Doctrine/Access.php
r4718 r4776 35 35 * @version $Revision$ 36 36 * @author Konsta Vesterinen <kvesteri@cc.hut.fi> 37 * @todo Consider making Collection & Entity implement ArrayAccess directly. 38 * This base class is not really a huge benefit. 37 * @todo Remove. 39 38 */ 40 39 abstract class Doctrine_Access implements ArrayAccess -
trunk/lib/Doctrine/Association.php
r4699 r4776 25 25 * Base class for association mappings. 26 26 * 27 * @author Roman Borschel <roman@code-factory.org> 27 28 * @since 2.0 28 * @author Roman Borschel <roman@code-factory.org>29 29 * @todo Rename to AssociationMapping. 30 30 */ … … 53 53 protected $_isCascadeRefresh; 54 54 55 protected $_customAccessor; 56 protected $_customMutator; 57 55 58 /** 56 59 * The fetch mode used for the association. … … 69 72 70 73 /** 74 * Whether the association is optional (0..X) or not (1..X). 75 * By default all associations are optional. 76 * 77 * @var boolean 78 */ 79 protected $_isOptional = true; 80 81 /** 71 82 * The name of the source Entity (the Entity that defines this mapping). 72 83 * … … 85 96 /** 86 97 * Identifies the field on the source class (the class this AssociationMapping 87 * belongs to) that represents the association. 98 * belongs to) that represents the association and stores the reference to the 99 * other entity/entities. 88 100 * 89 101 * @var string … … 107 119 public function __construct(array $mapping) 108 120 { 109 $this->_validateMapping($mapping); 110 if ($this->_isOwningSide) { 111 $this->_sourceEntityName = $mapping['sourceEntity']; 112 $this->_targetEntityName = $mapping['targetEntity']; 113 $this->_sourceFieldName = $mapping['fieldName']; 114 } else { 121 $this->_validateAndCompleteMapping($mapping); 122 123 $this->_sourceEntityName = $mapping['sourceEntity']; 124 $this->_targetEntityName = $mapping['targetEntity']; 125 $this->_sourceFieldName = $mapping['fieldName']; 126 127 if ( ! $this->_isOwningSide) { 115 128 $this->_mappedByFieldName = $mapping['mappedBy']; 116 129 } … … 123 136 * @return array The validated & completed mapping. 124 137 */ 125 protected function _validate Mapping(array $mapping)126 { 138 protected function _validateAndCompleteMapping(array $mapping) 139 { 127 140 if (isset($mapping['mappedBy'])) { 141 // Inverse side, mapping can be found on the owning side. 128 142 $this->_isOwningSide = false; 129 } 130 131 if ($this->_isOwningSide) { 132 if ( ! isset($mapping['targetEntity'])) { 133 throw Doctrine_MappingException::missingTargetEntity(); 134 } else if ( ! isset($mapping['fieldName'])) { 135 throw Doctrine_MappingException::missingFieldName(); 136 } 137 } 143 } else { 144 // Owning side 145 } 146 147 // Mandatory attributes 148 if ( ! isset($mapping['fieldName'])) { 149 throw Doctrine_MappingException::missingFieldName(); 150 } 151 if ( ! isset($mapping['sourceEntity'])) { 152 throw Doctrine_MappingException::missingSourceEntity($mapping['fieldName']); 153 } 154 if ( ! isset($mapping['targetEntity'])) { 155 throw Doctrine_MappingException::missingTargetEntity($mapping['fieldName']); 156 } 157 158 // Optional attributes 159 $this->_customAccessor = isset($mapping['accessor']) ? $mapping['accessor'] : null; 160 $this->_customMutator = isset($mapping['mutator']) ? $mapping['mutator'] : null; 161 $this->_isOptional = isset($mapping['isOptional']) ? (bool)$mapping['isOptional'] : true; 138 162 139 163 return $mapping; 140 164 } 141 165 166 protected function _validateAndCompleteInverseSideMapping() 167 { 168 169 } 170 171 protected function _validateAndCompleteOwningSideMapping() 172 { 173 174 } 175 176 /** 177 * Whether the association cascades delete() operations from the source entity 178 * to the target entity/entities. 179 * 180 * @return boolean 181 */ 142 182 public function isCascadeDelete() 143 183 { … … 148 188 } 149 189 190 /** 191 * Whether the association cascades save() operations from the source entity 192 * to the target entity/entities. 193 * 194 * @return boolean 195 */ 150 196 public function isCascadeSave() 151 197 { … … 156 202 } 157 203 204 /** 205 * Whether the association cascades refresh() operations from the source entity 206 * to the target entity/entities. 207 * 208 * @return boolean 209 */ 158 210 public function isCascadeRefresh() 159 211 { … … 164 216 } 165 217 218 /** 219 * Whether the target entity/entities of the association are eagerly fetched. 220 * 221 * @return boolean 222 */ 166 223 public function isEagerlyFetched() 167 224 { … … 169 226 } 170 227 228 /** 229 * Whether the target entity/entities of the association are lazily fetched. 230 * 231 * @return boolean 232 */ 171 233 public function isLazilyFetched() 172 234 { … … 174 236 } 175 237 238 /** 239 * Whether the target entity/entities of the association are manually fetched. 240 * 241 * @return boolean 242 */ 176 243 public function isManuallyFetched() 177 244 { … … 179 246 } 180 247 248 /** 249 * Whether the source entity of this association represents the owning side. 250 * 251 * @return boolean 252 */ 181 253 public function isOwningSide() 182 254 { … … 184 256 } 185 257 258 /** 259 * Whether the source entity of this association represents the inverse side. 260 * 261 * @return boolean 262 */ 186 263 public function isInverseSide() 187 264 { … … 189 266 } 190 267 268 /** 269 * Whether the association is optional (0..X), or not (1..X). 270 * 271 * @return boolean TRUE if the association is optional, FALSE otherwise. 272 */ 273 public function isOptional() 274 { 275 return $this->_isOptional; 276 } 277 278 /** 279 * Gets the name of the source entity class. 280 * 281 * @return string 282 */ 191 283 public function getSourceEntityName() 192 284 { … … 194 286 } 195 287 288 /** 289 * Gets the name of the target entity class. 290 * 291 * @return string 292 */ 196 293 public function getTargetEntityName() 197 294 { … … 202 299 * Get the name of the field the association is mapped into. 203 300 * 301 * @return string 204 302 */ 205 303 public function getSourceFieldName() … … 208 306 } 209 307 308 /** 309 * Gets the field name of the owning side in a bi-directional association. 310 * 311 * @return string 312 */ 210 313 public function getMappedByFieldName() 211 314 { 212 315 return $this->_mappedByFieldName; 316 } 317 318 /** 319 * Whether the source field of the association has a custom accessor. 320 * 321 * @return boolean TRUE if the source field of the association has a custom accessor, 322 * FALSE otherwise. 323 */ 324 public function hasCustomAccessor() 325 { 326 return isset($this->_customAccessor); 327 } 328 329 /** 330 * Gets the name of the custom accessor method of the source field. 331 * 332 * @return string The name of the accessor method or NULL. 333 */ 334 public function getCustomAccessor() 335 { 336 return $this->_customAccessor; 337 } 338 339 /** 340 * Whether the source field of the association has a custom mutator. 341 * 342 * @return boolean TRUE if the source field of the association has a custom mutator, 343 * FALSE otherwise. 344 */ 345 public function hasCustomMutator() 346 { 347 return isset($this->_customMutator); 348 } 349 350 /** 351 * Gets the name of the custom mutator method of the source field. 352 * 353 * @return string The name of the mutator method or NULL. 354 */ 355 public function getCustomMutator() 356 { 357 return $this->_customMutator; 358 } 359 360 public function isOneToOne() 361 { 362 return false; 363 } 364 365 public function isOneToMany() 366 { 367 return false; 368 } 369 370 public function isManyToMany() 371 { 372 return false; 213 373 } 214 374 -
trunk/lib/Doctrine/Association/OneToOne.php
r4718 r4776 107 107 108 108 /** 109 * Whether the association is one-to-one. 110 * 111 * @return boolean 112 * @override 113 */ 114 public function isOneToOne() 115 { 116 return true; 117 } 118 119 /** 109 120 * Lazy-loads the associated entity for a given entity. 110 121 * -
trunk/lib/Doctrine/ClassMetadata.php
r4723 r4776 49 49 50 50 /* The Entity types */ 51 // A regular entity is assumed to have persistent state that Doctrine should manage. 51 /** 52 * A regular entity is assumed to have persistent state that Doctrine should manage. 53 */ 52 54 const ENTITY_TYPE_REGULAR = 'regular'; 53 // A transient entity is ignored by Doctrine. 55 /** 56 * A transient entity is ignored by Doctrine. 57 */ 54 58 const ENTITY_TYPE_TRANSIENT = 'transient'; 55 // A mapped superclass entity is itself not persisted by Doctrine but it's 56 // field & association mappings are inherited by subclasses. 59 /** 60 * A mapped superclass entity is itself not persisted by Doctrine but it's 61 * field & association mappings are inherited by subclasses. 62 */ 57 63 const ENTITY_TYPE_MAPPED_SUPERCLASS = 'mappedSuperclass'; 58 64 … … 123 129 */ 124 130 protected $_generatorType = self::GENERATOR_TYPE_NONE; 125 126 /**127 * An array containing all behaviors attached to the class.128 *129 * @see Doctrine_Template130 * @var array $_templates131 * @todo Unify under 'Behaviors'.132 */133 //protected $_behaviors = array();134 131 135 132 /** … … 219 216 */ 220 217 protected $_lcColumnToFieldNames = array(); 221 222 /**223 * Enter description here...224 *225 * @var unknown_type226 */227 //protected $_subclassFieldNames = array();228 218 229 219 /** … … 311 301 */ 312 302 protected $_isIdentifierComposite = false; 303 304 protected $_customAssociationAccessors = array(); 305 protected $_customAssociationMutators = array(); 313 306 314 307 /** … … 316 309 * 317 310 * @param string $entityName Name of the entity class the metadata info is used for. 311 * @param Doctrine::ORM::Entitymanager $em 318 312 */ 319 313 public function __construct($entityName, Doctrine_EntityManager $em) … … 325 319 $this->_parser = new Doctrine_Relation_Parser($this); 326 320 } 327 328 /** 329 * @deprecated 330 */ 331 public function getConnection() 332 { 333 return $this->_em; 334 } 335 321 322 /** 323 * Gets the EntityManager that holds this ClassMetadata. 324 * 325 * @return Doctrine::ORM::EntityManager 326 */ 336 327 public function getEntityManager() 337 328 { … … 362 353 363 354 /** 364 * @deprecated365 */366 public function getComponentName()367 {368 return $this->getClassName();369 }370 371 /**372 355 * Checks whether a field is part of the identifier/primary key field(s). 373 356 * … … 430 413 431 414 /** 432 * addIndex433 *434 415 * adds an index to this table 435 416 * … … 460 441 461 442 /** 462 * setOption463 * sets an option and returns this object in order to464 * allow flexible method chaining465 *466 * @see Doctrine_Table::$_options for available options467 * @param string $name the name of the option to set468 * @param mixed $value the value of the option469 * @return Doctrine_Table this object470 * @deprecated471 */472 public function setOption($name, $value)473 {474 $this->_options[$name] = $value;475 }476 477 /**478 443 * Sets a table option. 479 444 */ … … 496 461 497 462 return $this->_tableOptions[$name]; 498 }499 500 /*public function getBehaviorForMethod($method)501 {502 return (isset($this->_invokedMethods[$method])) ?503 $this->_invokedMethods[$method] : false;504 }505 public function addBehaviorMethod($method, $behavior)506 {507 $this->_invokedMethods[$method] = $class;508 }*/509 510 /**511 * returns the value of given option512 *513 * @param string $name the name of the option514 * @return mixed the value of given option515 */516 public function getOption($name)517 {518 if (isset($this->_options[$name])) {519 return $this->_options[$name];520 } else if (isset($this->_tableOptions[$name])) {521 return $this->_tableOptions[$name];522 }523 return null;524 }525 526 /**527 * getOptions528 * returns all options of this table and the associated values529 *530 * @return array all options and their values531 */532 public function getOptions()533 {534 return $this->_options;535 463 } 536 464 … … 704 632 * Validates & completes the field mapping. Default values are applied here. 705 633 * 706 * @param array $mapping 707 * @return array 634 * @param array $mapping The field mapping to validated & complete. 635 * @return array The validated and completed field mapping. 708 636 */ 709 637 private function _validateAndCompleteFieldMapping(array $mapping) … … 802 730 803 731 /** 804 * Gets the names of all validators that are applied on a field.805 *806 * @param string The field name.807 * @return array The names of all validators that are applied on the specified field.808 */809 /*public function getFieldValidators($fieldName)810 {811 return isset($this->_fieldMappings[$fieldName]['validators']) ?812 $this->_fieldMappings[$fieldName]['validators'] : array();813 }*/814 815 /**816 732 * Gets the identifier (primary key) field names of the class. 817 733 * … … 872 788 public function getCustomAccessor($fieldName) 873 789 { 874 return isset($this->_fieldMappings[$fieldName]['accessor']) ? 875 $this->_fieldMappings[$fieldName]['accessor'] : null; 790 if (isset($this->_fieldMappings[$fieldName]['accessor'])) { 791 return $this->_fieldMappings[$fieldName]['accessor']; 792 } else if (isset($this->_customAssociationAccessors[$fieldName])) { 793 return $this->_customAssociationAccessors[$fieldName]; 794 } 795 return null; 876 796 } 877 797 … … 884 804 public function getCustomMutator($fieldName) 885 805 { 886 return isset($this->_fieldMappings[$fieldName]['mutator']) ? 887 $this->_fieldMappings[$fieldName]['mutator'] : null; 806 if (isset($this->_fieldMappings[$fieldName]['mutator'])) { 807 return $this->_fieldMappings[$fieldName]['mutator']; 808 } else if (isset($this->_customAssociationMutators[$fieldName])) { 809 return $this->_customAssociationMutators[$fieldName]; 810 } 811 return null; 888 812 } 889 813 … … 1055 979 1056 980 /** 1057 * getBehaviors1058 * returns all behaviors attached to the class.1059 *1060 * @return array an array containing all templates1061 * @todo Unify under 'Behaviors'1062 */1063 /*public function getBehaviors()1064 {1065 return $this->_behaviors;1066 }*/1067 1068 /**1069 981 * Gets the inheritance type used by the class. 1070 982 * … … 1157 1069 } 1158 1070 1159 if ($type == Doctrine::INHERITANCE_TYPE_SINGLE_TABLE ||1160 $type == Doctrine::INHERITANCE_TYPE_JOINED) {1071 if ($type == self::INHERITANCE_TYPE_SINGLE_TABLE || 1072 $type == self::INHERITANCE_TYPE_JOINED) { 1161 1073 $this->_checkRequiredDiscriminatorOptions($options); 1162 1074 } … … 1241 1153 1242 1154 /** 1243 * export1244 1155 * exports this class to the database based on its mapping. 1245 1156 * … … 1248 1159 * @return boolean Whether or not the export operation was successful 1249 1160 * false if table already existed in the database. 1161 * @todo Reimpl. & Placement. 1250 1162 */ 1251 1163 public function export() 1252 1164 { 1253 $this->_em->export->exportTable($this); 1254 } 1255 1256 /** 1257 * getExportableFormat 1165 //$this->_em->export->exportTable($this); 1166 } 1167 1168 /** 1258 1169 * Returns an array with all the information needed to create the main database table 1259 1170 * for the class. 1260 1171 * 1261 1172 * @return array 1173 * @todo Reimpl. & placement. 1262 1174 */ 1263 1175 public function getExportableFormat($parseForeignKeys = true) … … 1269 1181 // If the class is part of a Single Table Inheritance hierarchy, collect the fields 1270 1182 // of all classes in the hierarchy. 1271 if ($this->_inheritanceType == Doctrine::INHERITANCE_TYPE_SINGLE_TABLE) {1183 if ($this->_inheritanceType == self::INHERITANCE_TYPE_SINGLE_TABLE) { 1272 1184 $parents = $this->getParentClasses(); 1273 1185 if ($parents) { … … 1281 1193 $allColumns = array_merge($allColumns, $subClassMetadata->getColumns()); 1282 1194 } 1283 } else if ($this->_inheritanceType == Doctrine::INHERITANCE_TYPE_JOINED) {1195 } else if ($this->_inheritanceType == self::INHERITANCE_TYPE_JOINED) { 1284 1196 // Remove inherited, non-pk fields. They're not in the table of this class 1285 1197 foreach ($allColumns as $name => $definition) { …