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