Trac
- Timestamp:
- 08/16/08 20:40:59 (3 months ago)
- Files:
-
- trunk/lib/Doctrine/Access.php (modified) (1 diff)
- trunk/lib/Doctrine/Association.php (modified) (17 diffs)
- trunk/lib/Doctrine/Association/OneToOne.php (modified) (1 diff)
- trunk/lib/Doctrine/ClassMetadata.php (modified) (32 diffs)
- trunk/lib/Doctrine/ClassMetadata/Factory.php (modified) (5 diffs)
- trunk/lib/Doctrine/Collection.php (modified) (38 diffs)
- trunk/lib/Doctrine/CollectionPersister (added)
- trunk/lib/Doctrine/CollectionPersister/Abstract.php (added)
- trunk/lib/Doctrine/CollectionPersister/OneToManyPersister.php (added)
- trunk/lib/Doctrine/Connection/UnitOfWork.php (modified) (6 diffs)
- trunk/lib/Doctrine/DatabasePlatform.php (modified) (2 diffs)
- trunk/lib/Doctrine/DatabasePlatform/MySqlPlatform.php (modified) (1 diff)
- trunk/lib/Doctrine/DatabasePlatform/OraclePlatform.php (modified) (1 diff)
- trunk/lib/Doctrine/Entity.php (modified) (25 diffs)
- trunk/lib/Doctrine/EntityManager.php (modified) (16 diffs)
- trunk/lib/Doctrine/EntityPersister/Abstract.php (modified) (4 diffs)
- trunk/lib/Doctrine/EntityPersister/Standard.php (modified) (2 diffs)
- trunk/lib/Doctrine/EventManager.php (modified) (2 diffs)
- trunk/lib/Doctrine/Exception.php (modified) (1 diff)
- trunk/lib/Doctrine/Hydrator/RecordDriver.php (modified) (1 diff)
- trunk/lib/Doctrine/HydratorNew.php (modified) (2 diffs)
- trunk/lib/Doctrine/MappingException.php (modified) (2 diffs)
- trunk/lib/Doctrine/Query/CacheHandler.php (modified) (2 diffs)
- trunk/lib/Doctrine/Query/Production/Join.php (modified) (2 diffs)
- trunk/lib/Doctrine/Query/Production/PathExpression.php (modified) (1 diff)
- trunk/lib/Doctrine/Query/Production/PathExpressionEndingWithAsterisk.php (modified) (1 diff)
- trunk/lib/Doctrine/Query/Production/RangeVariableDeclaration.php (modified) (3 diffs)
- trunk/lib/Doctrine/Relation.php (modified) (1 diff)
- trunk/lib/Doctrine/Relation/Parser.php (modified) (1 diff)
- trunk/lib/Doctrine/Schema/MsSqlSchemaManager.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
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) { … … 1294 1206 } 1295 1207 } 1296 } else if ($this->_inheritanceType == Doctrine::INHERITANCE_TYPE_TABLE_PER_CLASS) {1208 } else if ($this->_inheritanceType == self::INHERITANCE_TYPE_TABLE_PER_CLASS) { 1297 1209 // If this is a subclass, just remove existing autoincrement options on the pk 1298 1210 if ($this->getParentClasses()) { … … 1424 1336 1425 1337 /** 1426 * Checks whether the given name identifies an entity type.1338 * Checks whether the given type identifies an entity type. 1427 1339 * 1428 1340 * @param string $type … … 1437 1349 1438 1350 /** 1439 * Checks whether the given name identifies an inheritance type.1351 * Checks whether the given type identifies an inheritance type. 1440 1352 * 1441 1353 * @param string $type … … 1451 1363 1452 1364 /** 1453 * Checks whether the given name identifies an id generator type.1365 * Checks whether the given type identifies an id generator type. 1454 1366 * 1455 1367 * @param string $type … … 1464 1376 $type == self::GENERATOR_TYPE_NONE; 1465 1377 } 1466 1378 1379 /** 1380 * Makes some automatic additions to the association mapping to make the life 1381 * easier for the user. 1382 * 1383 * @param array $mapping 1384 * @return unknown 1385 * @todo Pass param by ref? 1386 */ 1387 private function _completeAssociationMapping(array $mapping) 1388 { 1389 $mapping['sourceEntity'] = $this->_entityName; 1390 return $mapping; 1391 } 1392 1393 /** 1394 * Registers any custom accessors/mutators in the given association mapping in 1395 * an internal cache for fast lookup. 1396 * 1397 * @param Doctrine_Association $assoc 1398 * @param unknown_type $fieldName 1399 */ 1400 private function _registerCustomAssociationAccessors(Doctrine_Association $assoc, $fieldName) 1401 { 1402 if ($acc = $assoc->getCustomAccessor()) { 1403 $this->_customAssociationAccessors[$fieldName] = $acc; 1404 } 1405 if ($mut = $assoc->getCustomMutator()) { 1406 $this->_customAssociationMutators[$fieldName] = $mut; 1407 } 1408 } 1409 1467 1410 /** 1468 1411 * Adds a one-to-one association mapping. … … 1472 1415 public function mapOneToOne(array $mapping) 1473 1416 { 1417 $mapping = $this->_completeAssociationMapping($mapping); 1474 1418 $oneToOneMapping = new Doctrine_Association_OneToOne($mapping); 1475 if (isset($this->_associationMappings[$oneToOneMapping->getSourceFieldName()])) { 1419 $sourceFieldName = $oneToOneMapping->getSourceFieldName(); 1420 if (isset($this->_associationMappings[$sourceFieldName])) { 1476 1421 throw Doctrine_MappingException::duplicateFieldMapping(); 1477 1422 } 1478 $this->_associationMappings[$oneToOneMapping->getSourceFieldName()] = $oneToOneMapping; 1423 $this->_associationMappings[$sourceFieldName] = $oneToOneMapping; 1424 $this->_registerCustomAssociationAccessors($oneToOneMapping, $sourceFieldName); 1479 1425 } 1480 1426 … … 1484 1430 public function mapOneToMany(array $mapping) 1485 1431 { 1486 1432 $mapping = $this->_completeAssociationMapping($mapping); 1433 $oneToManyMapping = new Doctrine_Association_OneToMany($mapping); 1434 $sourceFieldName = $oneToManyMapping->getSourceFieldName(); 1435 if (isset($this->_associationMappings[$sourceFieldName])) { 1436 throw Doctrine_MappingException::duplicateFieldMapping(); 1437 } 1438 $this->_associationMappings[$sourceFieldName] = $oneToManyMapping; 1439 $this->_registerCustomAssociationAccessors($oneToManyMapping, $sourceFieldName); 1487 1440 } 1488 1441 … … 1502 1455 1503 1456 } 1504 1505 /**1506 * actAs1507 * loads the given plugin1508 *1509 * @param mixed $tpl1510 * @param array $options1511 * @todo Unify under 'Behaviors'.1512 */1513 /*public function actAs($tpl, array $options = array())1514 {1515 if ( ! is_object($tpl)) {1516 if (class_exists($tpl, true)) {1517 $tpl = new $tpl($options);1518 } else {1519 $className = 'Doctrine_Template_' . $tpl;1520 if ( ! class_exists($className, true)) {1521 throw new Doctrine_Record_Exception("Couldn't load plugin.");1522 }1523 $tpl = new $className($options);1524 }1525 }1526 1527 if ( ! ($tpl instanceof Doctrine_Template)) {1528 throw new Doctrine_Record_Exception('Loaded plugin class is not an instance of Doctrine_Template.');1529 }1530 1531 $className = get_class($tpl);1532 1533 $this->addBehavior($className, $tpl);1534 1535 $tpl->setTable($this);1536 $tpl->setUp();1537 $tpl->setTableDefinition();1538 1539 return $this;1540 }*/1541 1542 /**1543 * check1544 * adds a check constraint1545 *1546 * @param mixed $constraint either a SQL constraint portion or an array of CHECK constraints1547 * @param string $name optional constraint name1548 * @return Doctrine_Entity this object1549 * @todo Should be done through $_tableOptions1550 * @deprecated1551 */1552 /*public function check($constraint, $name = null)1553 {1554 if (is_array($constraint)) {1555 foreach ($constraint as $name => $def) {1556 $this->_addCheckConstraint($def, $name);1557 }1558 } else {1559 $this->_addCheckConstraint($constraint, $name);1560 }1561 1562 return $this;1563 }1564 protected function _addCheckConstraint($definition, $name)1565 {1566 if (is_string($name)) {1567 $this->_tableOptions['checks'][$name] = $definition;1568 } else {1569 $this->_tableOptions['checks'][] = $definition;1570 }1571 }*/1572 1457 1573 1458 /** … … 1575 1460 * 1576 1461 * @param string $mapperClassName The class name of the custom mapper. 1577 * @deprecated1578 1462 */ 1579 1463 public function setCustomRepositoryClass($repositoryClassName) … … 1608 1492 1609 1493 /** 1610 * Binds the entity instance of this class to a specific EntityManager.1494 * Binds the entity instances of this class to a specific EntityManager. 1611 1495 * 1612 1496 * @todo Implementation. Replaces the bindComponent() methods on the old Doctrine_Manager. … … 1698 1582 } 1699 1583 } 1700 1701 /** 1702 * @todo Implementation. Immutable entities can not be updated or deleted once 1703 * they are created. This means the entity can only be modified as long as it's 1704 * in transient state (TCLEAN, TDIRTY). 1705 */ 1706 public function isImmutable() 1707 { 1708 return false; 1709 } 1710 1711 public function isDiscriminatorColumn($columnName) 1712 { 1713 return $columnName === $this->_inheritanceOptions['discriminatorColumn']; 1714 } 1715 1716 /** 1717 * hasOne 1718 * binds One-to-One aggregate relation 1719 * 1720 * @param string $componentName the name of the related component 1721 * @param string $options relation options 1722 * @see Doctrine_Relation::_$definition 1723 * @return Doctrine_Entity this object 1724 */ 1725 public function hasOne() 1726 { 1727 $this->bind(func_get_args(), Doctrine_Relation::ONE_AGGREGATE); 1728 1729 return $this; 1730 } 1731 1732 /** 1733 * hasMany 1734 * binds One-to-Many / Many-to-Many aggregate relation 1735 * 1736 * @param string $componentName the name of the related component 1737 * @param string $options relation options 1738 * @see Doctrine_Relation::_$definition 1739 * @return Doctrine_Entity this object 1740 */ 1741 public function hasMany() 1742 { 1743 $this->bind(func_get_args(), Doctrine_Relation::MANY_AGGREGATE); 1744 1745 return $this; 1746 } 1747 1748 public function hasAttribute($name) 1749 { 1750 return isset($this->_attributes[$name]); 1751 } 1752 1753 public function getAttribute($name) 1754 { 1755 if ($this->hasAttribute($name)) { 1756 return $this->_attributes[$name]; 1757 } 1758 } 1759 1760 public function setAttribute($name, $value) 1761 { 1762 if ($this->hasAttribute($name)) { 1763 $this->_attributes[$name] = $value; 1764 } 1765 } 1766 1767 /* The following stuff needs to be touched for the association mapping rewrite */ 1768 1769 public function bindRelation($args, $type) 1770 { 1771 return $this->bind($args, $type); 1772 } 1773 1774 /** 1775 * @todo Relation mapping rewrite. 1776 */ 1777 public function bind($args, $type) 1778 { 1779 $options = array(); 1780 $options['type'] = $type; 1781 1782 if ( ! isset($args[1])) { 1783 $args[1] = array(); 1784 } 1785 if ( ! is_array($args[1])) { 1786 try { 1787 throw new Exception(); 1788 } catch (Exception $e) { 1789 echo $e->getTraceAsString(); 1790 } 1791 } 1792 $options = array_merge($args[1], $options); 1793 $this->_parser->bind($args[0], $options); 1794 } 1795 1796 /** 1797 * hasRelation 1798 * 1799 * @param string $alias the relation to check if exists 1800 * @return boolean true if the relation exists otherwise false 1801 */ 1802 public function hasRelation($alias) 1803 { 1804 return $this->_parser->hasRelation($alias); 1805 } 1806 1807 /** 1808 * getRelation 1809 * 1810 * @param string $alias relation alias 1811 */ 1812 public function getRelation($alias, $recursive = true) 1813 { 1814 return $this->_parser->getRelation($alias, $recursive); 1815 } 1816 1817 public function getRelationParser() 1818 { 1819 return $this->_parser; 1820 } 1821 1822 /** 1823 * getRelations 1824 * returns an array containing all relation objects 1825 * 1826 * @return array an array of Doctrine_Relation objects 1827 */ 1828 public function getRelations() 1829 { 1830 return $this->_parser->getRelations(); 1831 } 1832 1833 /** 1834 * @todo Set by the factory if type is AUTO. Not pretty. Find sth. better. 1835 */ 1836 public function setIdGeneratorType($type) 1837 { 1838 $this->_generatorType = $type; 1839 } 1840 1584 1585 /** 1586 * Completes the identifier mapping of the class. 1587 * NOTE: Should only be called by the ClassMetadataFactory! 1588 */ 1841 1589 public function completeIdentifierMapping() 1842 1590 { … … 1854 1602 1855 1603 /** 1604 * @todo Implementation. Immutable entities can not be updated or deleted once 1605 * they are created. This means the entity can only be modified as long as it's 1606 * in transient state (TCLEAN, TDIRTY). 1607 */ 1608 public function isImmutable() 1609 { 1610 return false; 1611 } 1612 1613 public function isDiscriminatorColumn($columnName) 1614 { 1615 return $columnName === $this->_inheritanceOptions['discriminatorColumn']; 1616 } 1617 1618 public function hasAttribute($name) 1619 { 1620 return isset($this->_attributes[$name]); 1621 } 1622 1623 public function getAttribute($name) 1624 { 1625 if ($this->hasAttribute($name)) { 1626 return $this->_attributes[$name]; 1627 } 1628 } 1629 16