Commit e79c45f9 authored by romanb's avatar romanb

[2.0] Fixed issues discovered during code coverage report generation. Made all...

[2.0] Fixed issues discovered during code coverage report generation. Made all ClassMetadata properties public (good reasons, read the class docblock). Performance improvements.
parent 8d956442
...@@ -7,7 +7,7 @@ class DoctrineException extends \Exception ...@@ -7,7 +7,7 @@ class DoctrineException extends \Exception
private $_innerException; private $_innerException;
private static $_messages = array(); private static $_messages = array();
public function __construct($message = "", Exception $innerException = null) public function __construct($message = "", \Exception $innerException = null)
{ {
parent::__construct($message); parent::__construct($message);
$this->_innerException = $innerException; $this->_innerException = $innerException;
...@@ -29,7 +29,7 @@ class DoctrineException extends \Exception ...@@ -29,7 +29,7 @@ class DoctrineException extends \Exception
$messageKey = substr($class, strrpos($class, '\\') + 1) . "#$method"; $messageKey = substr($class, strrpos($class, '\\') + 1) . "#$method";
$end = end($arguments); $end = end($arguments);
if ($end instanceof Exception) { if ($end instanceof \Exception) {
$this->_innerException = $end; $this->_innerException = $end;
unset($arguments[count($arguments) - 1]); unset($arguments[count($arguments) - 1]);
} }
......
...@@ -564,7 +564,7 @@ class Connection ...@@ -564,7 +564,7 @@ class Connection
* *
* @throws Doctrine\DBAL\ConnectionException * @throws Doctrine\DBAL\ConnectionException
*/ */
public function rethrowException(Exception $e, $invoker) public function rethrowException(\Exception $e, $invoker)
{ {
throw $e; throw $e;
} }
......
...@@ -51,8 +51,8 @@ abstract class Type ...@@ -51,8 +51,8 @@ abstract class Type
public static function getType($name) public static function getType($name)
{ {
if (is_object($name)) { if (is_object($name)) {
try { throw new Exception(); } try { throw new \Exception(); }
catch (Exception $e) { echo $e->getTraceAsString(); } catch (\Exception $e) { echo $e->getTraceAsString(); }
die(); die();
} }
if ( ! isset(self::$_typeObjects[$name])) { if ( ! isset(self::$_typeObjects[$name])) {
......
...@@ -98,7 +98,7 @@ class DynamicProxyGenerator ...@@ -98,7 +98,7 @@ class DynamicProxyGenerator
$file = self::$_proxyClassTemplate; $file = self::$_proxyClassTemplate;
$methods = ''; $methods = '';
foreach ($class->getReflectionClass()->getMethods() as $method) { foreach ($class->reflClass->getMethods() as $method) {
if ($method->isPublic() && ! $method->isFinal()) { if ($method->isPublic() && ! $method->isFinal()) {
$methods .= PHP_EOL . 'public function ' . $method->getName() . '('; $methods .= PHP_EOL . 'public function ' . $method->getName() . '(';
$firstParam = true; $firstParam = true;
...@@ -119,7 +119,7 @@ class DynamicProxyGenerator ...@@ -119,7 +119,7 @@ class DynamicProxyGenerator
} }
$sleepImpl = ''; $sleepImpl = '';
if ($class->getReflectionClass()->hasMethod('__sleep')) { if ($class->reflClass->hasMethod('__sleep')) {
$sleepImpl .= 'return parent::__sleep();'; $sleepImpl .= 'return parent::__sleep();';
} else { } else {
$sleepImpl .= 'return array('; $sleepImpl .= 'return array(';
...@@ -162,7 +162,7 @@ class DynamicProxyGenerator ...@@ -162,7 +162,7 @@ class DynamicProxyGenerator
$file = self::$_assocProxyClassTemplate; $file = self::$_assocProxyClassTemplate;
$methods = ''; $methods = '';
foreach ($class->getReflectionClass()->getMethods() as $method) { foreach ($class->reflClass->getMethods() as $method) {
if ($method->isPublic() && ! $method->isFinal()) { if ($method->isPublic() && ! $method->isFinal()) {
$methods .= PHP_EOL . 'public function ' . $method->getName() . '('; $methods .= PHP_EOL . 'public function ' . $method->getName() . '(';
$firstParam = true; $firstParam = true;
...@@ -183,7 +183,7 @@ class DynamicProxyGenerator ...@@ -183,7 +183,7 @@ class DynamicProxyGenerator
} }
$sleepImpl = ''; $sleepImpl = '';
if ($class->getReflectionClass()->hasMethod('__sleep')) { if ($class->reflClass->hasMethod('__sleep')) {
$sleepImpl .= 'return parent::__sleep();'; $sleepImpl .= 'return parent::__sleep();';
} else { } else {
$sleepImpl .= 'return array('; $sleepImpl .= 'return array(';
...@@ -228,7 +228,7 @@ namespace Doctrine\Generated\Proxies { ...@@ -228,7 +228,7 @@ namespace Doctrine\Generated\Proxies {
} }
private function _load() { private function _load() {
if ( ! $this->_loaded) { if ( ! $this->_loaded) {
$this->_em->getUnitOfWork()->getEntityPersister($this->_class->getClassName())->load($this->_identifier, $this); $this->_em->getUnitOfWork()->getEntityPersister($this->_class->name)->load($this->_identifier, $this);
unset($this->_em); unset($this->_em);
unset($this->_class); unset($this->_class);
$this->_loaded = true; $this->_loaded = true;
......
...@@ -40,7 +40,7 @@ class EntityRepository ...@@ -40,7 +40,7 @@ class EntityRepository
public function __construct($em, \Doctrine\ORM\Mapping\ClassMetadata $classMetadata) public function __construct($em, \Doctrine\ORM\Mapping\ClassMetadata $classMetadata)
{ {
$this->_entityName = $classMetadata->getClassName(); $this->_entityName = $classMetadata->name;
$this->_em = $em; $this->_em = $em;
$this->_classMetadata = $classMetadata; $this->_classMetadata = $classMetadata;
} }
...@@ -66,7 +66,7 @@ class EntityRepository ...@@ -66,7 +66,7 @@ class EntityRepository
*/ */
public function clear() public function clear()
{ {
$this->_em->getUnitOfWork()->clearIdentitiesForEntity($this->_classMetadata->getRootClassName()); $this->_em->getUnitOfWork()->clearIdentitiesForEntity($this->_classMetadata->rootEntityName);
} }
/** /**
...@@ -79,13 +79,13 @@ class EntityRepository ...@@ -79,13 +79,13 @@ class EntityRepository
public function find($id, $hydrationMode = null) public function find($id, $hydrationMode = null)
{ {
// Check identity map first // Check identity map first
if ($entity = $this->_em->getUnitOfWork()->tryGetById($id, $this->_classMetadata->getRootClassName())) { if ($entity = $this->_em->getUnitOfWork()->tryGetById($id, $this->_classMetadata->rootEntityName)) {
return $entity; // Hit! return $entity; // Hit!
} }
if ( ! is_array($id) || count($id) <= 1) { if ( ! is_array($id) || count($id) <= 1) {
$value = is_array($id) ? array_values($id) : array($id); $value = is_array($id) ? array_values($id) : array($id);
$id = array_combine($this->_classMetadata->getIdentifier(), $value); $id = array_combine($this->_classMetadata->identifier, $value);
} }
return $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName)->load($id); return $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName)->load($id);
......
...@@ -143,7 +143,7 @@ abstract class AbstractHydrator ...@@ -143,7 +143,7 @@ abstract class AbstractHydrator
*/ */
protected function _hydrateRow(array &$data, array &$cache, &$result) protected function _hydrateRow(array &$data, array &$cache, &$result)
{ {
throw new Exception("_hydrateRow() not implemented for this hydrator."); throw new DoctrineException("_hydrateRow() not implemented for this hydrator.");
} }
/** /**
...@@ -312,7 +312,7 @@ abstract class AbstractHydrator ...@@ -312,7 +312,7 @@ abstract class AbstractHydrator
return $class; return $class;
} }
foreach ($class->getSubclasses() as $subClass) { foreach ($class->subClasses as $subClass) {
$subClassMetadata = $this->_em->getClassMetadata($subClass); $subClassMetadata = $this->_em->getClassMetadata($subClass);
if ($subClassMetadata->hasField($fieldName)) { if ($subClassMetadata->hasField($fieldName)) {
return $subClassMetadata; return $subClassMetadata;
......
...@@ -63,14 +63,14 @@ class ObjectHydrator extends AbstractHydrator ...@@ -63,14 +63,14 @@ class ObjectHydrator extends AbstractHydrator
$this->_identifierMap[$dqlAlias] = array(); $this->_identifierMap[$dqlAlias] = array();
$this->_resultPointers[$dqlAlias] = array(); $this->_resultPointers[$dqlAlias] = array();
$this->_idTemplate[$dqlAlias] = ''; $this->_idTemplate[$dqlAlias] = '';
$this->_classMetadatas[$class->getClassName()] = $class; $this->_classMetadatas[$class->name] = $class;
if ($class->isInheritanceTypeSingleTable() || $class->isInheritanceTypeJoined()) { if ($class->isInheritanceTypeSingleTable() || $class->isInheritanceTypeJoined()) {
$this->_discriminatorMap[$class->getClassName()][$class->getDiscriminatorValue()] = $class->getClassName(); $this->_discriminatorMap[$class->name][$class->discriminatorValue] = $class->name;
foreach (array_merge($class->getParentClasses(), $class->getSubclasses()) as $className) { foreach (array_merge($class->parentClasses, $class->subClasses) as $className) {
$otherClass = $this->_em->getClassMetadata($className); $otherClass = $this->_em->getClassMetadata($className);
$value = $otherClass->getDiscriminatorValue(); $value = $otherClass->discriminatorValue;
$this->_classMetadatas[$className] = $otherClass; $this->_classMetadatas[$className] = $otherClass;
$this->_discriminatorMap[$class->getClassName()][$value] = $className; $this->_discriminatorMap[$class->name][$value] = $className;
} }
} }
if ($this->_resultSetMapping->isRelation($dqlAlias)) { if ($this->_resultSetMapping->isRelation($dqlAlias)) {
...@@ -79,7 +79,7 @@ class ObjectHydrator extends AbstractHydrator ...@@ -79,7 +79,7 @@ class ObjectHydrator extends AbstractHydrator
if ($mappedByField = $assoc->getMappedByFieldName()) { if ($mappedByField = $assoc->getMappedByFieldName()) {
$this->_fetchedAssociations[$assoc->getTargetEntityName()][$mappedByField] = true; $this->_fetchedAssociations[$assoc->getTargetEntityName()][$mappedByField] = true;
} else if ($inverseAssoc = $this->_em->getClassMetadata($assoc->getTargetEntityName()) } else if ($inverseAssoc = $this->_em->getClassMetadata($assoc->getTargetEntityName())
->getInverseAssociationMapping($assoc->getSourceFieldName())) { ->inverseMappings[$assoc->getSourceFieldName()]) {
$this->_fetchedAssociations[$assoc->getTargetEntityName()][ $this->_fetchedAssociations[$assoc->getTargetEntityName()][
$inverseAssoc->getSourceFieldName() $inverseAssoc->getSourceFieldName()
] = true; ] = true;
...@@ -188,7 +188,7 @@ class ObjectHydrator extends AbstractHydrator ...@@ -188,7 +188,7 @@ class ObjectHydrator extends AbstractHydrator
$coll = $this->getCollection($relatedClass); $coll = $this->getCollection($relatedClass);
$coll->setOwner($entity, $relation); $coll->setOwner($entity, $relation);
$classMetadata->getReflectionProperty($name)->setValue($entity, $coll); $classMetadata->reflFields[$name]->setValue($entity, $coll);
$this->_uow->setOriginalEntityProperty($oid, $name, $coll); $this->_uow->setOriginalEntityProperty($oid, $name, $coll);
$this->_initializedRelations[$oid][$name] = true; $this->_initializedRelations[$oid][$name] = true;
...@@ -206,7 +206,7 @@ class ObjectHydrator extends AbstractHydrator ...@@ -206,7 +206,7 @@ class ObjectHydrator extends AbstractHydrator
private function isIndexKeyInUse($entity, $assocField, $indexField) private function isIndexKeyInUse($entity, $assocField, $indexField)
{ {
return $this->_classMetadatas[get_class($entity)] return $this->_classMetadatas[get_class($entity)]
->getReflectionProperty($assocField) ->reflFields[$assocField]
->getValue($entity) ->getValue($entity)
->containsKey($indexField); ->containsKey($indexField);
} }
...@@ -234,7 +234,7 @@ class ObjectHydrator extends AbstractHydrator ...@@ -234,7 +234,7 @@ class ObjectHydrator extends AbstractHydrator
// Properly initialize any unfetched associations, if partial objects are not allowed. // Properly initialize any unfetched associations, if partial objects are not allowed.
if ( ! $this->_allowPartialObjects) { if ( ! $this->_allowPartialObjects) {
foreach ($this->_classMetadatas[$className]->getAssociationMappings() as $field => $assoc) { foreach ($this->_classMetadatas[$className]->associationMappings as $field => $assoc) {
if ( ! isset($this->_fetchedAssociations[$className][$field])) { if ( ! isset($this->_fetchedAssociations[$className][$field])) {
if ($assoc->isOneToOne()) { if ($assoc->isOneToOne()) {
if ($assoc->isLazilyFetched()) { if ($assoc->isLazilyFetched()) {
...@@ -246,7 +246,7 @@ class ObjectHydrator extends AbstractHydrator ...@@ -246,7 +246,7 @@ class ObjectHydrator extends AbstractHydrator
} }
} else { } else {
// Inject collection // Inject collection
$this->_classMetadatas[$className]->getReflectionProperty($field) $this->_classMetadatas[$className]->reflFields[$field]
->setValue($entity, new PersistentCollection($this->_em, ->setValue($entity, new PersistentCollection($this->_em,
$this->_em->getClassMetadata($assoc->getTargetEntityName()) $this->_em->getClassMetadata($assoc->getTargetEntityName())
)); ));
...@@ -268,7 +268,7 @@ class ObjectHydrator extends AbstractHydrator ...@@ -268,7 +268,7 @@ class ObjectHydrator extends AbstractHydrator
private function isFieldSet($entity, $field) private function isFieldSet($entity, $field)
{ {
return $this->_classMetadatas[get_class($entity)] return $this->_classMetadatas[get_class($entity)]
->getReflectionProperty($field) ->reflFields[$field]
->getValue($entity) !== null; ->getValue($entity) !== null;
} }
...@@ -282,7 +282,7 @@ class ObjectHydrator extends AbstractHydrator ...@@ -282,7 +282,7 @@ class ObjectHydrator extends AbstractHydrator
private function setRelatedElement($entity1, $property, $entity2) private function setRelatedElement($entity1, $property, $entity2)
{ {
$classMetadata1 = $this->_classMetadatas[get_class($entity1)]; $classMetadata1 = $this->_classMetadatas[get_class($entity1)];
$classMetadata1->getReflectionProperty($property)->setValue($entity1, $entity2); $classMetadata1->reflFields[$property]->setValue($entity1, $entity2);
$this->_uow->setOriginalEntityProperty(spl_object_hash($entity1), $property, $entity2); $this->_uow->setOriginalEntityProperty(spl_object_hash($entity1), $property, $entity2);
$relation = $classMetadata1->getAssociationMapping($property); $relation = $classMetadata1->getAssociationMapping($property);
if ($relation->isOneToOne()) { if ($relation->isOneToOne()) {
...@@ -290,12 +290,12 @@ class ObjectHydrator extends AbstractHydrator ...@@ -290,12 +290,12 @@ class ObjectHydrator extends AbstractHydrator
if ($relation->isOwningSide()) { if ($relation->isOwningSide()) {
// If there is an inverse mapping on the target class its bidirectional // If there is an inverse mapping on the target class its bidirectional
if ($targetClass->hasInverseAssociationMapping($property)) { if ($targetClass->hasInverseAssociationMapping($property)) {
$sourceProp = $targetClass->getInverseAssociationMapping($fieldName)->getSourceFieldName(); $sourceProp = $targetClass->inverseMappings[$fieldName]->getSourceFieldName();
$targetClass->getReflectionProperty($sourceProp)->setValue($entity2, $entity1); $targetClass->reflFields[$sourceProp]->setValue($entity2, $entity1);
} }
} else { } else {
// For sure bidirectional, as there is no inverse side in unidirectional // For sure bidirectional, as there is no inverse side in unidirectional
$targetClass->getReflectionProperty($relation->getMappedByFieldName())->setValue($entity2, $entity1); $targetClass->reflFields[$relation->getMappedByFieldName()]->setValue($entity2, $entity1);
} }
} }
} }
...@@ -321,7 +321,7 @@ class ObjectHydrator extends AbstractHydrator ...@@ -321,7 +321,7 @@ class ObjectHydrator extends AbstractHydrator
// Hydrate the entity data found in the current row. // Hydrate the entity data found in the current row.
foreach ($rowData as $dqlAlias => $data) { foreach ($rowData as $dqlAlias => $data) {
$index = false; $index = false;
$entityName = $this->_resultSetMapping->getClass($dqlAlias)->getClassName(); $entityName = $this->_resultSetMapping->getClass($dqlAlias)->name;
if ($this->_resultSetMapping->hasParentAlias($dqlAlias)) { if ($this->_resultSetMapping->hasParentAlias($dqlAlias)) {
// It's a joined result // It's a joined result
...@@ -363,7 +363,7 @@ class ObjectHydrator extends AbstractHydrator ...@@ -363,7 +363,7 @@ class ObjectHydrator extends AbstractHydrator
if ($relation->isManyToMany()) { if ($relation->isManyToMany()) {
if ($relation->isOwningSide()) { if ($relation->isOwningSide()) {
$reverseAssoc = $this->_classMetadatas[$entityName] $reverseAssoc = $this->_classMetadatas[$entityName]
->getInverseAssociationMapping($relationAlias); ->inverseMappings[$relationAlias];
if ($reverseAssoc) { if ($reverseAssoc) {
$this->initRelatedCollection($element, $reverseAssoc->getSourceFieldName()); $this->initRelatedCollection($element, $reverseAssoc->getSourceFieldName());
} }
...@@ -374,21 +374,21 @@ class ObjectHydrator extends AbstractHydrator ...@@ -374,21 +374,21 @@ class ObjectHydrator extends AbstractHydrator
if ($field = $this->_getCustomIndexField($dqlAlias)) { if ($field = $this->_getCustomIndexField($dqlAlias)) {
$indexValue = $this->_classMetadatas[$entityName] $indexValue = $this->_classMetadatas[$entityName]
->getReflectionProperty($field) ->reflFields[$field]
->getValue($element); ->getValue($element);
$this->_classMetadatas[$parentClass] $this->_classMetadatas[$parentClass]
->getReflectionProperty($relationAlias) ->reflFields[$relationAlias]
->getValue($baseElement) ->getValue($baseElement)
->set($indexValue, $element); ->set($indexValue, $element);
} else { } else {
$this->_classMetadatas[$parentClass] $this->_classMetadatas[$parentClass]
->getReflectionProperty($relationAlias) ->reflFields[$relationAlias]
->getValue($baseElement) ->getValue($baseElement)
->add($element); ->add($element);
} }
$this->_identifierMap[$path][$id[$parent]][$id[$dqlAlias]] = $this->getLastKey( $this->_identifierMap[$path][$id[$parent]][$id[$dqlAlias]] = $this->getLastKey(
$this->_classMetadatas[$parentClass] $this->_classMetadatas[$parentClass]
->getReflectionProperty($relationAlias) ->reflFields[$relationAlias]
->getValue($baseElement) ->getValue($baseElement)
); );
} }
...@@ -406,7 +406,7 @@ class ObjectHydrator extends AbstractHydrator ...@@ -406,7 +406,7 @@ class ObjectHydrator extends AbstractHydrator
} }
$coll = $this->_classMetadatas[$parentClass] $coll = $this->_classMetadatas[$parentClass]
->getReflectionProperty($relationAlias) ->reflFields[$relationAlias]
->getValue($baseElement); ->getValue($baseElement);
if ($coll !== null) { if ($coll !== null) {
...@@ -423,13 +423,13 @@ class ObjectHydrator extends AbstractHydrator ...@@ -423,13 +423,13 @@ class ObjectHydrator extends AbstractHydrator
if ($this->_resultSetMapping->isMixedResult()) { if ($this->_resultSetMapping->isMixedResult()) {
$result[] = array( $result[] = array(
$this->_classMetadatas[$entityName] $this->_classMetadatas[$entityName]
->getReflectionProperty($field) ->reflFields[$field]
->getValue($element) => $element ->getValue($element) => $element
); );
++$this->_resultCounter; ++$this->_resultCounter;
} else { } else {
$result->set($element, $this->_classMetadatas[$entityName] $result->set($element, $this->_classMetadatas[$entityName]
->getReflectionProperty($field) ->reflFields[$field]
->getValue($element)); ->getValue($element));
} }
} else { } else {
......
This diff is collapsed.
...@@ -135,20 +135,20 @@ class ClassMetadataFactory ...@@ -135,20 +135,20 @@ class ClassMetadataFactory
foreach ($parentClasses as $className) { foreach ($parentClasses as $className) {
$class = $this->_newClassMetadataInstance($className); $class = $this->_newClassMetadataInstance($className);
if ($parent) { if ($parent) {
$class->setInheritanceType($parent->getInheritanceType()); $class->setInheritanceType($parent->inheritanceType);
//$class->setDiscriminatorMap($parent->getDiscriminatorMap()); //$class->setDiscriminatorMap($parent->getDiscriminatorMap());
$class->setDiscriminatorColumn($parent->getDiscriminatorColumn()); $class->setDiscriminatorColumn($parent->discriminatorColumn);
$class->setIdGeneratorType($parent->getIdGeneratorType()); $class->setIdGeneratorType($parent->generatorType);
$this->_addInheritedFields($class, $parent); $this->_addInheritedFields($class, $parent);
$this->_addInheritedRelations($class, $parent); $this->_addInheritedRelations($class, $parent);
$class->setIdentifier($parent->getIdentifier()); $class->setIdentifier($parent->identifier);
} }
// Invoke driver // Invoke driver
$this->_driver->loadMetadataForClass($className, $class); $this->_driver->loadMetadataForClass($className, $class);
// Verify & complete identifier mapping // Verify & complete identifier mapping
if ( ! $class->getIdentifier()) { if ( ! $class->identifier) {
throw MappingException::identifierRequired($className); throw MappingException::identifierRequired($className);
} }
if ($parent) { if ($parent) {
...@@ -157,7 +157,7 @@ class ClassMetadataFactory ...@@ -157,7 +157,7 @@ class ClassMetadataFactory
} else if ($parent->isIdGeneratorTable()) { } else if ($parent->isIdGeneratorTable()) {
$class->getTableGeneratorDefinition($parent->getTableGeneratorDefinition()); $class->getTableGeneratorDefinition($parent->getTableGeneratorDefinition());
} }
$class->setIdGeneratorType($parent->getIdGeneratorType()); $class->setIdGeneratorType($parent->generatorType);
$class->setidGenerator($parent->getIdGenerator()); $class->setidGenerator($parent->getIdGenerator());
} else { } else {
$this->_completeIdGeneratorMapping($class); $this->_completeIdGeneratorMapping($class);
...@@ -193,9 +193,9 @@ class ClassMetadataFactory ...@@ -193,9 +193,9 @@ class ClassMetadataFactory
*/ */
private function _addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass) private function _addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass)
{ {
foreach ($parentClass->getFieldMappings() as $fieldName => $mapping) { foreach ($parentClass->fieldMappings as $fieldName => $mapping) {
if ( ! isset($mapping['inherited'])) { if ( ! isset($mapping['inherited'])) {
$mapping['inherited'] = $parentClass->getClassName(); $mapping['inherited'] = $parentClass->name;
} }
$subClass->addFieldMapping($mapping); $subClass->addFieldMapping($mapping);
$subClass->addReflectionProperty($fieldName, $parentClass->getReflectionProperty($fieldName)); $subClass->addReflectionProperty($fieldName, $parentClass->getReflectionProperty($fieldName));
...@@ -210,7 +210,7 @@ class ClassMetadataFactory ...@@ -210,7 +210,7 @@ class ClassMetadataFactory
*/ */
private function _addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass) private function _addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass)
{ {
foreach ($parentClass->getAssociationMappings() as $mapping) { foreach ($parentClass->associationMappings as $mapping) {
$subClass->addAssociationMapping($mapping); $subClass->addAssociationMapping($mapping);
} }
} }
...@@ -223,7 +223,7 @@ class ClassMetadataFactory ...@@ -223,7 +223,7 @@ class ClassMetadataFactory
*/ */
private function _completeIdGeneratorMapping(ClassMetadata $class) private function _completeIdGeneratorMapping(ClassMetadata $class)
{ {
$idGenType = $class->getIdGeneratorType(); $idGenType = $class->generatorType;
if ($idGenType == ClassMetadata::GENERATOR_TYPE_AUTO) { if ($idGenType == ClassMetadata::GENERATOR_TYPE_AUTO) {
if ($this->_targetPlatform->prefersSequences()) { if ($this->_targetPlatform->prefersSequences()) {
$class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_SEQUENCE); $class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_SEQUENCE);
...@@ -235,7 +235,7 @@ class ClassMetadataFactory ...@@ -235,7 +235,7 @@ class ClassMetadataFactory
} }
// Create & assign an appropriate ID generator instance // Create & assign an appropriate ID generator instance
switch ($class->getIdGeneratorType()) { switch ($class->generatorType) {
case ClassMetadata::GENERATOR_TYPE_IDENTITY: case ClassMetadata::GENERATOR_TYPE_IDENTITY:
$class->setIdGenerator(new \Doctrine\ORM\Id\IdentityGenerator()); $class->setIdGenerator(new \Doctrine\ORM\Id\IdentityGenerator());
break; break;
......
...@@ -159,7 +159,7 @@ class OneToOneMapping extends AssociationMapping ...@@ -159,7 +159,7 @@ class OneToOneMapping extends AssociationMapping
if ($targetClass->hasInverseAssociation($this->_sourceFieldName)) { if ($targetClass->hasInverseAssociation($this->_sourceFieldName)) {
$targetClass->setFieldValue( $targetClass->setFieldValue(
$targetEntity, $targetEntity,
$targetClass->getInverseAssociationMapping($this->_sourceFieldName)->getSourceFieldName(), $targetClass->inverseMappings[$this->_sourceFieldName]->getSourceFieldName(),
$owningEntity); $owningEntity);
} }
} else { } else {
......
...@@ -123,7 +123,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection ...@@ -123,7 +123,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
public function __construct(EntityManager $em, $class, array $data = array()) public function __construct(EntityManager $em, $class, array $data = array())
{ {
parent::__construct($data); parent::__construct($data);
$this->_type = $class->getClassName(); $this->_type = $class->name;
$this->_em = $em; $this->_em = $em;
$this->_ownerClass = $class; $this->_ownerClass = $class;
} }
...@@ -168,8 +168,8 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection ...@@ -168,8 +168,8 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
$targetClass = $this->_em->getClassMetadata($assoc->getTargetEntityName()); $targetClass = $this->_em->getClassMetadata($assoc->getTargetEntityName());
if ($targetClass->hasInverseAssociationMapping($assoc->getSourceFieldName())) { if ($targetClass->hasInverseAssociationMapping($assoc->getSourceFieldName())) {
// bi-directional // bi-directional
$this->_backRefFieldName = $targetClass->getInverseAssociationMapping( $this->_backRefFieldName = $targetClass->inverseMappings[
$assoc->getSourceFieldName())->getSourceFieldName(); $assoc->getSourceFieldName()]->getSourceFieldName();
} }
} }
} }
......
...@@ -80,7 +80,7 @@ abstract class AbstractEntityPersister ...@@ -80,7 +80,7 @@ abstract class AbstractEntityPersister
public function __construct(EntityManager $em, ClassMetadata $class) public function __construct(EntityManager $em, ClassMetadata $class)
{ {
$this->_em = $em; $this->_em = $em;
$this->_entityName = $class->getClassName(); $this->_entityName = $class->name;
$this->_conn = $em->getConnection(); $this->_conn = $em->getConnection();
$this->_class = $class; $this->_class = $class;
} }
...@@ -262,7 +262,7 @@ abstract class AbstractEntityPersister ...@@ -262,7 +262,7 @@ abstract class AbstractEntityPersister
$stmt->execute(array_values($criteria)); $stmt->execute(array_values($criteria));
$data = array(); $data = array();
foreach ($stmt->fetch(\PDO::FETCH_ASSOC) as $column => $value) { foreach ($stmt->fetch(\PDO::FETCH_ASSOC) as $column => $value) {
$fieldName = $this->_class->getFieldNameForLowerColumnName($column); $fieldName = $this->_class->lcColumnToFieldNames[$column];
$data[$fieldName] = Type::getType($this->_class->getTypeOfField($fieldName)) $data[$fieldName] = Type::getType($this->_class->getTypeOfField($fieldName))
->convertToPHPValue($value); ->convertToPHPValue($value);
} }
...@@ -276,7 +276,7 @@ abstract class AbstractEntityPersister ...@@ -276,7 +276,7 @@ abstract class AbstractEntityPersister
} }
$id = array(); $id = array();
if ($this->_class->isIdentifierComposite()) { if ($this->_class->isIdentifierComposite()) {
$identifierFieldNames = $this->_class->getIdentifier(); $identifierFieldNames = $this->_class->identifier;
foreach ($identifierFieldNames as $fieldName) { foreach ($identifierFieldNames as $fieldName) {
$id[] = $data[$fieldName]; $id[] = $data[$fieldName];
} }
...@@ -287,7 +287,7 @@ abstract class AbstractEntityPersister ...@@ -287,7 +287,7 @@ abstract class AbstractEntityPersister
} }
if ( ! $this->_em->getConfiguration()->getAllowPartialObjects()) { if ( ! $this->_em->getConfiguration()->getAllowPartialObjects()) {
foreach ($this->_class->getAssociationMappings() as $field => $assoc) { foreach ($this->_class->associationMappings as $field => $assoc) {
if ($assoc->isOneToOne()) { if ($assoc->isOneToOne()) {
if ($assoc->isLazilyFetched()) { if ($assoc->isLazilyFetched()) {
// Inject proxy // Inject proxy
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
namespace Doctrine\ORM\Persisters; namespace Doctrine\ORM\Persisters;
use Doctrine\Common\DoctrineException;
/** /**
* The joined subclass persister maps a single entity instance to several tables in the * The joined subclass persister maps a single entity instance to several tables in the
* database as it is defined by <tt>Class Table Inheritance</tt>. * database as it is defined by <tt>Class Table Inheritance</tt>.
...@@ -41,7 +43,7 @@ class JoinedSubclassPersister extends AbstractEntityPersister ...@@ -41,7 +43,7 @@ class JoinedSubclassPersister extends AbstractEntityPersister
* @return boolean * @return boolean
* @override * @override
*/ */
public function insert($entity) /*public function insert($entity)
{ {
$class = $entity->getClass(); $class = $entity->getClass();
...@@ -51,8 +53,8 @@ class JoinedSubclassPersister extends AbstractEntityPersister ...@@ -51,8 +53,8 @@ class JoinedSubclassPersister extends AbstractEntityPersister
$dataSet = $this->_groupFieldsByDefiningClass($class, $dataSet); $dataSet = $this->_groupFieldsByDefiningClass($class, $dataSet);
$component = $class->getClassName(); $component = $class->name;
$classes = $class->getParentClasses(); $classes = $class->parentClasses;
array_unshift($classes, $component); array_unshift($classes, $component);
$identifier = null; $identifier = null;
...@@ -66,12 +68,12 @@ class JoinedSubclassPersister extends AbstractEntityPersister ...@@ -66,12 +68,12 @@ class JoinedSubclassPersister extends AbstractEntityPersister
$seq = $entity->getClassMetadata()->getTableOption('sequenceName'); $seq = $entity->getClassMetadata()->getTableOption('sequenceName');
if ( ! empty($seq)) { if ( ! empty($seq)) {
$id = $this->_conn->getSequenceManager()->nextId($seq); $id = $this->_conn->getSequenceManager()->nextId($seq);
$identifierFields = $parentClass->getIdentifier(); $identifierFields = $parentClass->identifier;
$dataSet[$parent][$identifierFields[0]] = $id; $dataSet[$parent][$identifierFields[0]] = $id;
$this->_insertRow($parentClass->getTableName(), $dataSet[$parent]); $this->_insertRow($parentClass->getTableName(), $dataSet[$parent]);
} }
} else { } else {
throw \Doctrine\Common\DoctrineException::updateMe("Unsupported identifier type '$identifierType'."); throw DoctrineException::updateMe("Unsupported identifier type '$identifierType'.");
} }
$entity->_assignIdentifier($identifier); $entity->_assignIdentifier($identifier);
} else { } else {
...@@ -83,7 +85,7 @@ class JoinedSubclassPersister extends AbstractEntityPersister ...@@ -83,7 +85,7 @@ class JoinedSubclassPersister extends AbstractEntityPersister
} }
return true; return true;
} }*/
/** /**
* Updates an entity that is part of a Class Table Inheritance hierarchy. * Updates an entity that is part of a Class Table Inheritance hierarchy.
...@@ -91,14 +93,14 @@ class JoinedSubclassPersister extends AbstractEntityPersister ...@@ -91,14 +93,14 @@ class JoinedSubclassPersister extends AbstractEntityPersister
* @param Doctrine_Entity $record record to be updated * @param Doctrine_Entity $record record to be updated
* @return boolean whether or not the update was successful * @return boolean whether or not the update was successful
*/ */
protected function _doUpdate($entity) /*protected function _doUpdate($entity)
{ {
$conn = $this->_conn; $conn = $this->_conn;
$classMetadata = $this->_classMetadata; $classMetadata = $this->_classMetadata;
$identifier = $this->_convertFieldToColumnNames($record->identifier(), $classMetadata); $identifier = $this->_convertFieldToColumnNames($record->identifier(), $classMetadata);
$dataSet = $this->_groupFieldsByDefiningClass($record); $dataSet = $this->_groupFieldsByDefiningClass($record);
$component = $classMetadata->getClassName(); $component = $classMetadata->name;
$classes = $classMetadata->getParentClasses(); $classes = $classMetadata->parentClasses;
array_unshift($classes, $component); array_unshift($classes, $component);
foreach ($record as $field => $value) { foreach ($record as $field => $value) {
...@@ -119,13 +121,13 @@ class JoinedSubclassPersister extends AbstractEntityPersister ...@@ -119,13 +121,13 @@ class JoinedSubclassPersister extends AbstractEntityPersister
$record->assignIdentifier(true); $record->assignIdentifier(true);
return true; return true;
} }*/
/** /**
* Deletes an entity that is part of a Class Table Inheritance hierarchy. * Deletes an entity that is part of a Class Table Inheritance hierarchy.
* *
*/ */
protected function _doDelete(Doctrine_ORM_Entity $record) /*protected function _doDelete(Doctrine_ORM_Entity $record)
{ {
$conn = $this->_conn; $conn = $this->_conn;
try { try {
...@@ -139,7 +141,7 @@ class JoinedSubclassPersister extends AbstractEntityPersister ...@@ -139,7 +141,7 @@ class JoinedSubclassPersister extends AbstractEntityPersister
// run deletions, starting from the class, upwards the hierarchy // run deletions, starting from the class, upwards the hierarchy
$conn->delete($class->getTableName(), $identifier); $conn->delete($class->getTableName(), $identifier);
foreach ($class->getParentClasses() as $parent) { foreach ($class->parentClasses as $parent) {
$parentClass = $conn->getClassMetadata($parent); $parentClass = $conn->getClassMetadata($parent);
$this->_deleteRow($parentClass->getTableName(), $identifier); $this->_deleteRow($parentClass->getTableName(), $identifier);
} }
...@@ -154,7 +156,7 @@ class JoinedSubclassPersister extends AbstractEntityPersister ...@@ -154,7 +156,7 @@ class JoinedSubclassPersister extends AbstractEntityPersister
} }
return true; return true;
} }*/
/** /**
* Adds all parent classes as INNER JOINs and subclasses as OUTER JOINs * Adds all parent classes as INNER JOINs and subclasses as OUTER JOINs
...@@ -164,21 +166,21 @@ class JoinedSubclassPersister extends AbstractEntityPersister ...@@ -164,21 +166,21 @@ class JoinedSubclassPersister extends AbstractEntityPersister
* *
* @return array The custom joins in the format <className> => <joinType> * @return array The custom joins in the format <className> => <joinType>
*/ */
public function getCustomJoins() /*public function getCustomJoins()
{ {
$customJoins = array(); $customJoins = array();
$classMetadata = $this->_classMetadata; $classMetadata = $this->_classMetadata;
foreach ($classMetadata->getParentClasses() as $parentClass) { foreach ($classMetadata->parentClasses as $parentClass) {
$customJoins[$parentClass] = 'INNER'; $customJoins[$parentClass] = 'INNER';
} }
foreach ($classMetadata->getSubclasses() as $subClass) { foreach ($classMetadata->subClasses as $subClass) {
if ($subClass != $this->getComponentName()) { if ($subClass != $this->getComponentName()) {
$customJoins[$subClass] = 'LEFT'; $customJoins[$subClass] = 'LEFT';
} }
} }
return $customJoins; return $customJoins;
} }*/
/** /**
* Adds the discriminator column to the selected fields in a query as well as * Adds the discriminator column to the selected fields in a query as well as
...@@ -189,34 +191,34 @@ class JoinedSubclassPersister extends AbstractEntityPersister ...@@ -189,34 +191,34 @@ class JoinedSubclassPersister extends AbstractEntityPersister
* *
* @return array An array with the field names that will get added to the query. * @return array An array with the field names that will get added to the query.
*/ */
public function getCustomFields() /*public function getCustomFields()
{ {
$classMetadata = $this->_classMetadata; $classMetadata = $this->_classMetadata;
$conn = $this->_conn; $conn = $this->_conn;
$discrColumn = $classMetadata->getDiscriminatorColumn(); $discrColumn = $classMetadata->discriminatorColumn;
$fields = array($discrColumn['name']); $fields = array($discrColumn['name']);
if ($classMetadata->getSubclasses()) { if ($classMetadata->subClasses) {
foreach ($classMetadata->getSubclasses() as $subClass) { foreach ($classMetadata->subClasses as $subClass) {
$fields = array_merge($conn->getClassMetadata($subClass)->getFieldNames(), $fields); $fields = array_merge($conn->getClassMetadata($subClass)->fieldNames, $fields);
} }
} }
return array_unique($fields); return array_unique($fields);
} }*/
/** /**
* *
*/ */
public function getFieldNames() /*public function getFieldNames()
{ {
if ($this->_fieldNames) { if ($this->_fieldNames) {
return $this->_fieldNames; return $this->_fieldNames;
} }
$fieldNames = $this->_classMetadata->getFieldNames(); $fieldNames = $this->_classMetadata->fieldNames;
$this->_fieldNames = array_unique($fieldNames); $this->_fieldNames = array_unique($fieldNames);
return $fieldNames; return $fieldNames;
} }*/
/** /**
* *
...@@ -230,14 +232,14 @@ class JoinedSubclassPersister extends AbstractEntityPersister ...@@ -230,14 +232,14 @@ class JoinedSubclassPersister extends AbstractEntityPersister
return $classMetadata; return $classMetadata;
} }
foreach ($classMetadata->getParentClasses() as $parentClass) { foreach ($classMetadata->parentClasses as $parentClass) {
$parentTable = $conn->getClassMetadata($parentClass); $parentTable = $conn->getClassMetadata($parentClass);
if ($parentTable->hasField($fieldName) && ! $parentTable->isInheritedField($fieldName)) { if ($parentTable->hasField($fieldName) && ! $parentTable->isInheritedField($fieldName)) {
return $parentTable; return $parentTable;
} }
} }
foreach ((array)$classMetadata->getSubclasses() as $subClass) { foreach ((array)$classMetadata->subClasses as $subClass) {
$subTable = $conn->getClassMetadata($subClass); $subTable = $conn->getClassMetadata($subClass);
if ($subTable->hasField($fieldName) && ! $subTable->isInheritedField($fieldName)) { if ($subTable->hasField($fieldName) && ! $subTable->isInheritedField($fieldName)) {
return $subTable; return $subTable;
...@@ -253,17 +255,17 @@ class JoinedSubclassPersister extends AbstractEntityPersister ...@@ -253,17 +255,17 @@ class JoinedSubclassPersister extends AbstractEntityPersister
* *
* @return array * @return array
*/ */
protected function _groupFieldsByDefiningClass(Doctrine_ClassMetadata $class, array $fields) /*protected function _groupFieldsByDefiningClass(Doctrine_ClassMetadata $class, array $fields)
{ {
$dataSet = array(); $dataSet = array();
$component = $class->getClassName(); $component = $class->name;
$classes = array_merge(array($component), $class->getParentClasses()); $classes = array_merge(array($component), $class->parentClasses);
foreach ($classes as $class) { foreach ($classes as $class) {
$dataSet[$class] = array(); $dataSet[$class] = array();
$parentClassMetadata = $this->_em->getClassMetadata($class); $parentClassMetadata = $this->_em->getClassMetadata($class);
foreach ($parentClassMetadata->getFieldMappings() as $fieldName => $mapping) { foreach ($parentClassMetadata->fieldMappings as $fieldName => $mapping) {
if ((isset($mapping['id']) && $mapping['id'] === true) || if ((isset($mapping['id']) && $mapping['id'] === true) ||
(isset($mapping['inherited']) && $mapping['inherited'] === true)) { (isset($mapping['inherited']) && $mapping['inherited'] === true)) {
continue; continue;
...@@ -277,5 +279,5 @@ class JoinedSubclassPersister extends AbstractEntityPersister ...@@ -277,5 +279,5 @@ class JoinedSubclassPersister extends AbstractEntityPersister
} }
return $dataSet; return $dataSet;
} }*/
} }
\ No newline at end of file
...@@ -39,8 +39,8 @@ class SingleTablePersister extends AbstractEntityPersister ...@@ -39,8 +39,8 @@ class SingleTablePersister extends AbstractEntityPersister
parent::_prepareData($entity, $result, $isInsert); parent::_prepareData($entity, $result, $isInsert);
// Populate the discriminator column // Populate the discriminator column
if ($isInsert) { if ($isInsert) {
$discColumn = $this->_class->getDiscriminatorColumn(); $discColumn = $this->_class->discriminatorColumn;
$result[$discColumn['name']] = $this->_class->getDiscriminatorValue(); $result[$discColumn['name']] = $this->_class->discriminatorValue;
} }
} }
} }
\ No newline at end of file
...@@ -36,23 +36,23 @@ class StandardEntityPersister extends AbstractEntityPersister ...@@ -36,23 +36,23 @@ class StandardEntityPersister extends AbstractEntityPersister
/** /**
* Deletes an entity. * Deletes an entity.
*/ */
protected function _doDelete($record) /*protected function _doDelete($record)
{ {
} }*/
/** /**
* Inserts a single entity into the database. * Inserts a single entity into the database.
* *
* @param Doctrine\ORM\Entity $entity The entity to insert. * @param Doctrine\ORM\Entity $entity The entity to insert.
*/ */
protected function _doInsert(Doctrine_ORM_Entity $record) /*protected function _doInsert(Doctrine_ORM_Entity $record)
{ {
} }*/
/** /**
* Updates an entity. * Updates an entity.
*/ */
protected function _doUpdate(Doctrine_ORM_Entity $record) /*protected function _doUpdate(Doctrine_ORM_Entity $record)
{ {
} }*/
} }
\ No newline at end of file
...@@ -39,7 +39,7 @@ class RangeVariableDeclaration extends Node ...@@ -39,7 +39,7 @@ class RangeVariableDeclaration extends Node
public function __construct($classMetadata, $aliasIdentificationVar) public function __construct($classMetadata, $aliasIdentificationVar)
{ {
$this->_classMetadata = $classMetadata; $this->_classMetadata = $classMetadata;
$this->_abstractSchemaName = $classMetadata->getClassName(); $this->_abstractSchemaName = $classMetadata->name;
$this->_aliasIdentificationVariable = $aliasIdentificationVar; $this->_aliasIdentificationVariable = $aliasIdentificationVar;
} }
......
...@@ -388,7 +388,7 @@ class Parser ...@@ -388,7 +388,7 @@ class Parser
if (count($parts) == 2) { if (count($parts) == 2) {
$expr->setIsSimpleStateFieldPathExpression(true); $expr->setIsSimpleStateFieldPathExpression(true);
if ( ! $qComps[$dqlAlias]['metadata']->hasField($parts[1])) { if ( ! $qComps[$dqlAlias]['metadata']->hasField($parts[1])) {
$this->semanticalError('The class ' . $qComps[$dqlAlias]['metadata']->getClassName() $this->semanticalError('The class ' . $qComps[$dqlAlias]['metadata']->name
. ' has no simple state field named ' . $parts[1]); . ' has no simple state field named ' . $parts[1]);
} }
} else { } else {
...@@ -422,7 +422,7 @@ class Parser ...@@ -422,7 +422,7 @@ class Parser
} }
// Last part MUST be a simple state field // Last part MUST be a simple state field
if ( ! $qComps[$dqlAlias]['metadata']->hasField($parts[$numParts-1])) { if ( ! $qComps[$dqlAlias]['metadata']->hasField($parts[$numParts-1])) {
$this->semanticalError('The class ' . $qComps[$dqlAlias]['metadata']->getClassName() $this->semanticalError('The class ' . $qComps[$dqlAlias]['metadata']->name
. ' has no simple state field named ' . $parts[$numParts-1]); . ' has no simple state field named ' . $parts[$numParts-1]);
} }
} }
...@@ -791,7 +791,7 @@ class Parser ...@@ -791,7 +791,7 @@ class Parser
$parentClass = $this->_queryComponents[$joinPathExpression->getIdentificationVariable()]['metadata']; $parentClass = $this->_queryComponents[$joinPathExpression->getIdentificationVariable()]['metadata'];
$assocField = $joinPathExpression->getAssociationField(); $assocField = $joinPathExpression->getAssociationField();
if ( ! $parentClass->hasAssociation($assocField)) { if ( ! $parentClass->hasAssociation($assocField)) {
$this->semanticalError("Class " . $parentClass->getClassName() . $this->semanticalError("Class " . $parentClass->name .
" has no association named '$assocField'."); " has no association named '$assocField'.");
} }
$targetClassName = $parentClass->getAssociationMapping($assocField)->getTargetEntityName(); $targetClassName = $parentClass->getAssociationMapping($assocField)->getTargetEntityName();
...@@ -911,7 +911,7 @@ class Parser ...@@ -911,7 +911,7 @@ class Parser
$class = $this->_em->getClassMetadata($assoc->getTargetEntityName()); $class = $this->_em->getClassMetadata($assoc->getTargetEntityName());
$assocSeen = true; $assocSeen = true;
} else { } else {
$this->semanticalError('The class ' . $class->getClassName() . $this->semanticalError('The class ' . $class->name .
' has no field or association named ' . $part); ' has no field or association named ' . $part);
} }
$parts[] = $part; $parts[] = $part;
......
...@@ -131,10 +131,10 @@ class SqlWalker ...@@ -131,10 +131,10 @@ class SqlWalker
//if ($this->_query->getHydrationMode() == \Doctrine\ORM\Query::HYDRATE_OBJECT) { //if ($this->_query->getHydrationMode() == \Doctrine\ORM\Query::HYDRATE_OBJECT) {
if ($class->isInheritanceTypeSingleTable() || $class->isInheritanceTypeJoined()) { if ($class->isInheritanceTypeSingleTable() || $class->isInheritanceTypeJoined()) {
$tblAlias = $this->getSqlTableAlias($class->getTableName()); $tblAlias = $this->getSqlTableAlias($class->getTableName());
$discrColumn = $class->getDiscriminatorColumn(); $discrColumn = $class->discriminatorColumn;
$columnAlias = $this->getSqlColumnAlias($discrColumn['name']); $columnAlias = $this->getSqlColumnAlias($discrColumn['name']);
$sql .= ", $tblAlias." . $discrColumn['name'] . ' AS ' . $columnAlias; $sql .= ", $tblAlias." . $discrColumn['name'] . ' AS ' . $columnAlias;
$this->_resultSetMapping->setDiscriminatorColumn($class->getClassName(), $dqlAlias, $columnAlias); $this->_resultSetMapping->setDiscriminatorColumn($class->name, $dqlAlias, $columnAlias);
} }
//} //}
} }
...@@ -392,11 +392,11 @@ class SqlWalker ...@@ -392,11 +392,11 @@ class SqlWalker
$sqlTableAlias = $this->getSqlTableAlias($class->getTableName()); $sqlTableAlias = $this->getSqlTableAlias($class->getTableName());
// Gather all fields // Gather all fields
$fieldMappings = $class->getFieldMappings(); $fieldMappings = $class->fieldMappings;
foreach ($class->getSubclasses() as $subclassName) { foreach ($class->subClasses as $subclassName) {
$fieldMappings = array_merge( $fieldMappings = array_merge(
$fieldMappings, $fieldMappings,
$this->_em->getClassMetadata($subclassName)->getFieldMappings() $this->_em->getClassMetadata($subclassName)->fieldMappings
); );
} }
...@@ -713,11 +713,11 @@ class SqlWalker ...@@ -713,11 +713,11 @@ class SqlWalker
$class = $this->_queryComponents[$dqlAlias]['metadata']; $class = $this->_queryComponents[$dqlAlias]['metadata'];
if ($class->isInheritanceTypeSingleTable()) { if ($class->isInheritanceTypeSingleTable()) {
$conn = $this->_em->getConnection(); $conn = $this->_em->getConnection();
$values = array($conn->quote($class->getDiscriminatorValue())); $values = array($conn->quote($class->discriminatorValue));
foreach ($class->getSubclasses() as $subclassName) { foreach ($class->subClasses as $subclassName) {
$values[] = $conn->quote($this->_em->getClassMetadata($subclassName)->getDiscriminatorValue()); $values[] = $conn->quote($this->_em->getClassMetadata($subclassName)->discriminatorValue);
} }
$discrColumn = $class->getDiscriminatorColumn(); $discrColumn = $class->discriminatorColumn;
if ($this->_useSqlTableAliases) { if ($this->_useSqlTableAliases) {
$sql .= $this->getSqlTableAlias($class->getTableName()) . '.'; $sql .= $this->getSqlTableAlias($class->getTableName()) . '.';
} }
......
...@@ -84,7 +84,7 @@ class SchemaTool ...@@ -84,7 +84,7 @@ class SchemaTool
// First we create the tables // First we create the tables
foreach ($classes as $class) { foreach ($classes as $class) {
if (isset($processedClasses[$class->getClassName()])) { if (isset($processedClasses[$class->name])) {
continue; continue;
} }
...@@ -99,11 +99,11 @@ class SchemaTool ...@@ -99,11 +99,11 @@ class SchemaTool
$columns[$discrColumnDef['name']] = $discrColumnDef; $columns[$discrColumnDef['name']] = $discrColumnDef;
// Aggregate all the information from all classes in the hierarchy // Aggregate all the information from all classes in the hierarchy
foreach ($class->getParentClasses() as $parentClassName) { foreach ($class->parentClasses as $parentClassName) {
// Parent class information is already contained in this class // Parent class information is already contained in this class
$processedClasses[$parentClassName] = true; $processedClasses[$parentClassName] = true;
} }
foreach ($class->getSubclasses() as $subClassName) { foreach ($class->subClasses as $subClassName) {
$subClass = $this->_em->getClassMetadata($subClassName); $subClass = $this->_em->getClassMetadata($subClassName);
$columns = array_merge($columns, $this->_gatherColumns($subClass, $options)); $columns = array_merge($columns, $this->_gatherColumns($subClass, $options));
$this->_gatherRelationsSql($subClass, $sql, $columns, $foreignKeyConstraints); $this->_gatherRelationsSql($subClass, $sql, $columns, $foreignKeyConstraints);
...@@ -116,7 +116,7 @@ class SchemaTool ...@@ -116,7 +116,7 @@ class SchemaTool
} }
$sql = array_merge($sql, $this->_platform->getCreateTableSql($class->getTableName(), $columns, $options)); $sql = array_merge($sql, $this->_platform->getCreateTableSql($class->getTableName(), $columns, $options));
$processedClasses[$class->getClassName()] = true; $processedClasses[$class->name] = true;
if ($class->isIdGeneratorSequence()) { if ($class->isIdGeneratorSequence()) {
$seqDef = $class->getSequenceGeneratorDefinition(); $seqDef = $class->getSequenceGeneratorDefinition();
...@@ -143,7 +143,7 @@ class SchemaTool ...@@ -143,7 +143,7 @@ class SchemaTool
private function _getDiscriminatorColumnDefinition($class) private function _getDiscriminatorColumnDefinition($class)
{ {
$discrColumn = $class->getDiscriminatorColumn(); $discrColumn = $class->discriminatorColumn;
return array( return array(
'name' => $discrColumn['name'], 'name' => $discrColumn['name'],
'type' => Type::getType($discrColumn['type']), 'type' => Type::getType($discrColumn['type']),
...@@ -155,7 +155,7 @@ class SchemaTool ...@@ -155,7 +155,7 @@ class SchemaTool
private function _gatherColumns($class, array &$options) private function _gatherColumns($class, array &$options)
{ {
$columns = array(); $columns = array();
foreach ($class->getFieldMappings() as $fieldName => $mapping) { foreach ($class->fieldMappings as $fieldName => $mapping) {
$column = array(); $column = array();
$column['name'] = $mapping['columnName']; $column['name'] = $mapping['columnName'];
$column['type'] = Type::getType($mapping['type']); $column['type'] = Type::getType($mapping['type']);
...@@ -176,7 +176,7 @@ class SchemaTool ...@@ -176,7 +176,7 @@ class SchemaTool
private function _gatherRelationsSql($class, array &$sql, array &$columns, array &$constraints) private function _gatherRelationsSql($class, array &$sql, array &$columns, array &$constraints)
{ {
foreach ($class->getAssociationMappings() as $mapping) { foreach ($class->associationMappings as $mapping) {
$foreignClass = $this->_em->getClassMetadata($mapping->getTargetEntityName()); $foreignClass = $this->_em->getClassMetadata($mapping->getTargetEntityName());
if ($mapping->isOneToOne() && $mapping->isOwningSide()) { if ($mapping->isOneToOne() && $mapping->isOwningSide()) {
$constraint = array(); $constraint = array();
......
This diff is collapsed.
...@@ -735,7 +735,7 @@ class ObjectHydratorTest extends HydrationTest ...@@ -735,7 +735,7 @@ class ObjectHydratorTest extends HydrationTest
) )
); );
for ($i = 4; $i < 1000; ++$i) { for ($i = 4; $i < 10000; ++$i) {
$resultSet[] = array( $resultSet[] = array(
'u__id' => $i, 'u__id' => $i,
'u__status' => 'developer', 'u__status' => 'developer',
......
...@@ -45,7 +45,7 @@ class ResultSetMappingTest extends \Doctrine\Tests\OrmTestCase ...@@ -45,7 +45,7 @@ class ResultSetMappingTest extends \Doctrine\Tests\OrmTestCase
$this->assertTrue($this->_rsm->getClass('u') instanceof ClassMetadata); $this->assertTrue($this->_rsm->getClass('u') instanceof ClassMetadata);
$class = $this->_rsm->getOwningClass('id'); $class = $this->_rsm->getOwningClass('id');
$this->assertTrue($class instanceof ClassMetadata); $this->assertTrue($class instanceof ClassMetadata);
$this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $class->getClassName()); $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $class->name);
$this->assertEquals('u', $this->_rsm->getEntityAlias('id')); $this->assertEquals('u', $this->_rsm->getEntityAlias('id'));
$this->assertEquals('u', $this->_rsm->getEntityAlias('status')); $this->assertEquals('u', $this->_rsm->getEntityAlias('status'));
......
...@@ -34,18 +34,18 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase ...@@ -34,18 +34,18 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase
$cmf->setMetadataForClass('Doctrine\Tests\ORM\Mapping\TestEntity1', $cm1); $cmf->setMetadataForClass('Doctrine\Tests\ORM\Mapping\TestEntity1', $cm1);
// Prechecks // Prechecks
$this->assertEquals(array(), $cm1->getParentClasses()); $this->assertEquals(array(), $cm1->parentClasses);
$this->assertEquals('none', $cm1->getInheritanceType()); $this->assertEquals('none', $cm1->inheritanceType);
$this->assertTrue($cm1->hasField('name')); $this->assertTrue($cm1->hasField('name'));
$this->assertEquals(1, count($cm1->getAssociationMappings())); $this->assertEquals(1, count($cm1->associationMappings));
$this->assertEquals('auto', $cm1->getIdGeneratorType()); $this->assertEquals('auto', $cm1->generatorType);
// Go // Go
$cm1 = $cmf->getMetadataFor('Doctrine\Tests\ORM\Mapping\TestEntity1'); $cm1 = $cmf->getMetadataFor('Doctrine\Tests\ORM\Mapping\TestEntity1');
$this->assertEquals(array(), $cm1->getParentClasses()); $this->assertEquals(array(), $cm1->parentClasses);
$this->assertTrue($cm1->hasField('name')); $this->assertTrue($cm1->hasField('name'));
$this->assertEquals('sequence', $cm1->getIdGeneratorType()); $this->assertEquals('sequence', $cm1->generatorType);
} }
} }
......
...@@ -14,11 +14,11 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase ...@@ -14,11 +14,11 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
// Test initial state // Test initial state
$this->assertTrue(count($cm->getReflectionProperties()) == 0); $this->assertTrue(count($cm->getReflectionProperties()) == 0);
$this->assertTrue($cm->getReflectionClass() instanceof \ReflectionClass); $this->assertTrue($cm->reflClass instanceof \ReflectionClass);
$this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->getClassName()); $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->name);
$this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->getRootClassName()); $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->rootEntityName);
$this->assertEquals(array(), $cm->getSubclasses()); $this->assertEquals(array(), $cm->subClasses);
$this->assertEquals(array(), $cm->getParentClasses()); $this->assertEquals(array(), $cm->parentClasses);
// Customize state // Customize state
$cm->setSubclasses(array("One", "Two", "Three")); $cm->setSubclasses(array("One", "Two", "Three"));
...@@ -27,22 +27,22 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase ...@@ -27,22 +27,22 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
$cm->setDiscriminatorColumn(array('name' => 'disc', 'type' => 'integer')); $cm->setDiscriminatorColumn(array('name' => 'disc', 'type' => 'integer'));
$cm->mapOneToOne(array('fieldName' => 'phonenumbers', 'targetEntity' => 'Bar', 'mappedBy' => 'foo')); $cm->mapOneToOne(array('fieldName' => 'phonenumbers', 'targetEntity' => 'Bar', 'mappedBy' => 'foo'));
$this->assertTrue($cm->getAssociationMapping('phonenumbers') instanceof \Doctrine\ORM\Mapping\OneToOneMapping); $this->assertTrue($cm->getAssociationMapping('phonenumbers') instanceof \Doctrine\ORM\Mapping\OneToOneMapping);
$this->assertEquals(1, count($cm->getAssociationMappings())); $this->assertEquals(1, count($cm->associationMappings));
$serialized = serialize($cm); $serialized = serialize($cm);
$cm = unserialize($serialized); $cm = unserialize($serialized);
// Check state // Check state
$this->assertTrue(count($cm->getReflectionProperties()) > 0); $this->assertTrue(count($cm->getReflectionProperties()) > 0);
$this->assertTrue($cm->getReflectionClass() instanceof \ReflectionClass); $this->assertTrue($cm->reflClass instanceof \ReflectionClass);
$this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->getClassName()); $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->name);
$this->assertEquals('UserParent', $cm->getRootClassName()); $this->assertEquals('UserParent', $cm->rootEntityName);
$this->assertEquals(array('One', 'Two', 'Three'), $cm->getSubclasses()); $this->assertEquals(array('One', 'Two', 'Three'), $cm->subClasses);
$this->assertEquals(array('UserParent'), $cm->getParentClasses()); $this->assertEquals(array('UserParent'), $cm->parentClasses);
$this->assertEquals('UserRepository', $cm->getCustomRepositoryClass()); $this->assertEquals('UserRepository', $cm->getCustomRepositoryClass());
$this->assertEquals(array('name' => 'disc', 'type' => 'integer'), $cm->getDiscriminatorColumn()); $this->assertEquals(array('name' => 'disc', 'type' => 'integer'), $cm->discriminatorColumn);
$this->assertTrue($cm->getAssociationMapping('phonenumbers') instanceof \Doctrine\ORM\Mapping\OneToOneMapping); $this->assertTrue($cm->getAssociationMapping('phonenumbers') instanceof \Doctrine\ORM\Mapping\OneToOneMapping);
$this->assertEquals(1, count($cm->getAssociationMappings())); $this->assertEquals(1, count($cm->associationMappings));
$oneOneMapping = $cm->getAssociationMapping('phonenumbers'); $oneOneMapping = $cm->getAssociationMapping('phonenumbers');
$this->assertEquals('phonenumbers', $oneOneMapping->getSourceFieldName()); $this->assertEquals('phonenumbers', $oneOneMapping->getSourceFieldName());
$this->assertEquals('Doctrine\Tests\Models\CMS\Bar', $oneOneMapping->getTargetEntityName()); $this->assertEquals('Doctrine\Tests\Models\CMS\Bar', $oneOneMapping->getTargetEntityName());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment