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 {
......
......@@ -28,6 +28,16 @@ use Doctrine\Common\DoctrineException;
* A <tt>ClassMetadata</tt> instance holds all the ORM metadata of an entity and
* it's associations. It is the backbone of Doctrine's metadata mapping.
*
* <b>IMPORTANT NOTE:</b>
*
* The fields of this class are only public for 2 reasons:
* 1) To allow fast READ access.
* 2) To drastically reduce the size of a serialized instance (private/protected members
* get the whole class name, namespace inclusive, prepended to every property in
* the serialized representation).
*
* !! Do NOT write/modify the public properties directly. Go through the public API. !!
*
* @author Roman Borschel <roman@code-factory.org>
* @since 2.0
*/
......@@ -108,14 +118,14 @@ final class ClassMetadata
/**
* The name of the entity class.
*/
private $_entityName;
public $name;
/**
* The namespace the entity class is contained in.
*
* @var string
*/
private $_namespace;
public $namespace;
/**
* The name of the entity class that is at the root of the entity inheritance
......@@ -124,7 +134,7 @@ final class ClassMetadata
*
* @var string
*/
private $_rootEntityName;
public $rootEntityName;
/**
* The name of the custom repository class used for the entity class.
......@@ -132,21 +142,21 @@ final class ClassMetadata
*
* @var string
*/
private $_customRepositoryClassName;
public $customRepositoryClassName;
/**
* The names of the parent classes (ancestors).
*
* @var array
*/
private $_parentClasses = array();
public $parentClasses = array();
/**
* The names of all subclasses.
*
* @var array
*/
private $_subClasses = array();
public $subClasses = array();
/**
* The field names of all fields that are part of the identifier/primary key
......@@ -154,21 +164,21 @@ final class ClassMetadata
*
* @var array
*/
private $_identifier = array();
public $identifier = array();
/**
* The inheritance mapping type used by the class.
*
* @var integer
*/
private $_inheritanceType = self::INHERITANCE_TYPE_NONE;
public $inheritanceType = self::INHERITANCE_TYPE_NONE;
/**
* The Id generator type used by the class.
*
* @var string
*/
private $_generatorType = self::GENERATOR_TYPE_NONE;
public $generatorType = self::GENERATOR_TYPE_NONE;
/**
* The field mappings of the class.
......@@ -226,7 +236,7 @@ final class ClassMetadata
*
* @var array
*/
private $_fieldMappings = array();
public $fieldMappings = array();
/**
* An array of field names. Used to look up field names from column names.
......@@ -235,7 +245,7 @@ final class ClassMetadata
*
* @var array
*/
private $_fieldNames = array();
public $fieldNames = array();
/**
* An array of column names. Keys are field names and values column names.
......@@ -244,7 +254,7 @@ final class ClassMetadata
*
* @var array
*/
private $_columnNames = array();
public $columnNames = array();
/**
* Map that maps lowercased column names (keys) to field names (values).
......@@ -253,7 +263,7 @@ final class ClassMetadata
*
* @var array
*/
private $_lcColumnToFieldNames = array();
public $lcColumnToFieldNames = array();
/**
* Whether to automatically OUTER JOIN subtypes when a basetype is queried.
......@@ -262,19 +272,18 @@ final class ClassMetadata
*
* @var boolean
*/
private $_joinSubclasses = true;
public $joinSubclasses = true;
/**
* A map that maps discriminator values to class names.
* The discriminator value of this class.
*
* <b>This does only apply to the JOINED and SINGLE_TABLE inheritance mapping strategies
* where a discriminator column is used.</b>
*
* @var array
* @var mixed
* @see _discriminatorColumn
*/
//private $_discriminatorMap = array();
private $_discriminatorValue;
public $discriminatorValue;
/**
* The definition of the descriminator column used in JOINED and SINGLE_TABLE
......@@ -282,7 +291,7 @@ final class ClassMetadata
*
* @var array
*/
private $_discriminatorColumn;
public $discriminatorColumn;
/**
* The primary table definition. The definition is an array with the
......@@ -294,7 +303,7 @@ final class ClassMetadata
*
* @var array
*/
private $_primaryTable;
public $primaryTable;
/**
* The cached lifecycle listeners. There is only one instance of each
......@@ -302,56 +311,56 @@ final class ClassMetadata
*
* @var array
*/
private $_lifecycleListenerInstances = array();
public $lifecycleListenerInstances = array();
/**
* The registered lifecycle callbacks for entities of this class.
*
* @var array
*/
private $_lifecycleCallbacks = array();
public $lifecycleCallbacks = array();
/**
* The registered lifecycle listeners for entities of this class.
*
* @var array
*/
private $_lifecycleListeners = array();
public $lifecycleListeners = array();
/**
* The association mappings. All mappings, inverse and owning side.
*
* @var array
*/
private $_associationMappings = array();
public $associationMappings = array();
/**
* List of inverse association mappings, indexed by mappedBy field name.
*
* @var array
*/
private $_inverseMappings = array();
public $inverseMappings = array();
/**
* Flag indicating whether the identifier/primary key of the class is composite.
*
* @var boolean
*/
private $_isIdentifierComposite = false;
public $isIdentifierComposite = false;
/**
* The ReflectionClass instance of the mapped class.
*
* @var ReflectionClass
*/
private $_reflectionClass;
public $reflClass;
/**
* The ReflectionProperty instances of the mapped class.
*
* @var array
*/
private $_reflectionProperties;
public $reflFields;
//private $_insertSql;
......@@ -360,7 +369,7 @@ final class ClassMetadata
*
* @var AbstractIdGenerator
*/
private $_idGenerator;
public $idGenerator;
/**
* The definition of the sequence generator of this class. Only used for the
......@@ -368,7 +377,7 @@ final class ClassMetadata
*
* @var array
*/
private $_sequenceGeneratorDefinition;
public $sequenceGeneratorDefinition;
/**
* The definition of the table generator of this class. Only used for the
......@@ -383,7 +392,7 @@ final class ClassMetadata
*
* @var integer
*/
private $_changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT;
public $changeTrackingPolicy = self::CHANGETRACKING_DEFERRED_IMPLICIT;
/**
* Initializes a new ClassMetadata instance that will hold the object-relational mapping
......@@ -393,11 +402,11 @@ final class ClassMetadata
*/
public function __construct($entityName)
{
$this->_entityName = $entityName;
$this->_namespace = substr($entityName, 0, strrpos($entityName, '\\'));
$this->_primaryTable['name'] = str_replace($this->_namespace . '\\', '', $this->_entityName);
$this->_rootEntityName = $entityName;
$this->_reflectionClass = new ReflectionClass($entityName);
$this->name = $entityName;
$this->namespace = substr($entityName, 0, strrpos($entityName, '\\'));
$this->primaryTable['name'] = str_replace($this->namespace . '\\', '', $this->name);
$this->rootEntityName = $entityName;
$this->reflClass = new ReflectionClass($entityName);
}
/**
......@@ -407,7 +416,7 @@ final class ClassMetadata
*/
public function getReflectionClass()
{
return $this->_reflectionClass;
return $this->reflClass;
}
/**
......@@ -417,7 +426,7 @@ final class ClassMetadata
*/
public function getReflectionProperties()
{
return $this->_reflectionProperties;
return $this->reflFields;
}
/**
......@@ -427,7 +436,7 @@ final class ClassMetadata
*/
public function getChangeTrackingPolicy()
{
return $this->_changeTrackingPolicy;
return $this->changeTrackingPolicy;
}
/**
......@@ -437,7 +446,7 @@ final class ClassMetadata
*/
public function setChangeTrackingPolicy($policy)
{
$this->_changeTrackingPolicy = $policy;
$this->changeTrackingPolicy = $policy;
}
/**
......@@ -447,7 +456,7 @@ final class ClassMetadata
*/
public function isChangeTrackingDeferredExplicit()
{
return $this->_changeTrackingPolicy == self::CHANGETRACKING_DEFERRED_EXPLICIT;
return $this->changeTrackingPolicy == self::CHANGETRACKING_DEFERRED_EXPLICIT;
}
/**
......@@ -455,9 +464,9 @@ final class ClassMetadata
*
* @return boolean
*/
public function isChangeTrackingPolicyDeferredImplicit()
public function isChangeTrackingDeferredImplicit()
{
return $this->_changeTrackingPolicy == self::CHANGETRACKING_DEFERRED_IMPLICIT;
return $this->changeTrackingPolicy == self::CHANGETRACKING_DEFERRED_IMPLICIT;
}
/**
......@@ -467,7 +476,7 @@ final class ClassMetadata
*/
public function isChangeTrackingNotify()
{
return $this->_changeTrackingPolicy == self::CHANGETRACKING_NOTIFY;
return $this->changeTrackingPolicy == self::CHANGETRACKING_NOTIFY;
}
/**
......@@ -479,7 +488,7 @@ final class ClassMetadata
*/
public function addReflectionProperty($propName, \ReflectionProperty $property)
{
$this->_reflectionProperties[$propName] = $property;
$this->reflFields[$propName] = $property;
}
/**
......@@ -490,7 +499,7 @@ final class ClassMetadata
*/
public function getReflectionProperty($name)
{
return $this->_reflectionProperties[$name];
return $this->reflFields[$name];
}
/**
......@@ -501,10 +510,10 @@ final class ClassMetadata
*/
public function getSingleIdReflectionProperty()
{
if ($this->_isIdentifierComposite) {
if ($this->isIdentifierComposite) {
throw DoctrineException::updateMe("getSingleIdReflectionProperty called on entity with composite key.");
}
return $this->_reflectionProperties[$this->_identifier[0]];
return $this->reflFields[$this->identifier[0]];
}
/**
......@@ -514,7 +523,7 @@ final class ClassMetadata
*/
public function getClassName()
{
return $this->_entityName;
return $this->name;
}
/**
......@@ -526,8 +535,8 @@ final class ClassMetadata
*/
public function getOwningClass($fieldName)
{
if ($this->_inheritanceType == self::INHERITANCE_TYPE_NONE) {
return $this->_entityName;
if ($this->inheritanceType == self::INHERITANCE_TYPE_NONE) {
return $this->name;
} else {
$mapping = $this->getFieldMapping($fieldName);
return $mapping['inherited'];
......@@ -543,7 +552,7 @@ final class ClassMetadata
*/
public function getRootClassName()
{
return $this->_rootEntityName;
return $this->rootEntityName;
}
/**
......@@ -555,10 +564,10 @@ final class ClassMetadata
*/
public function isIdentifier($fieldName)
{
if ( ! $this->_isIdentifierComposite) {
return $fieldName === $this->_identifier[0];
if ( ! $this->isIdentifierComposite) {
return $fieldName === $this->identifier[0];
}
return in_array($fieldName, $this->_identifier);
return in_array($fieldName, $this->identifier);
}
/**
......@@ -569,7 +578,7 @@ final class ClassMetadata
*/
public function isIdentifierComposite()
{
return $this->_isIdentifierComposite;
return $this->isIdentifierComposite;
}
/**
......@@ -612,8 +621,8 @@ final class ClassMetadata
*/
public function getColumnName($fieldName)
{
return isset($this->_columnNames[$fieldName]) ?
$this->_columnNames[$fieldName] : $fieldName;
return isset($this->columnNames[$fieldName]) ?
$this->columnNames[$fieldName] : $fieldName;
}
/**
......@@ -625,10 +634,10 @@ final class ClassMetadata
*/
public function getFieldMapping($fieldName)
{
if ( ! isset($this->_fieldMappings[$fieldName])) {
if ( ! isset($this->fieldMappings[$fieldName])) {
throw MappingException::mappingNotFound($fieldName);
}
return $this->_fieldMappings[$fieldName];
return $this->fieldMappings[$fieldName];
}
/**
......@@ -640,10 +649,10 @@ final class ClassMetadata
*/
public function getAssociationMapping($fieldName)
{
if ( ! isset($this->_associationMappings[$fieldName])) {
if ( ! isset($this->associationMappings[$fieldName])) {
throw MappingException::mappingNotFound($fieldName);
}
return $this->_associationMappings[$fieldName];
return $this->associationMappings[$fieldName];
}
/**
......@@ -654,8 +663,7 @@ final class ClassMetadata
*/
public function getInverseAssociationMapping($mappedByFieldName)
{
return isset($this->_inverseMappings[$mappedByFieldName]) ?
$this->_inverseMappings[$mappedByFieldName] : null;
return $this->inverseMappings[$mappedByFieldName];
}
/**
......@@ -666,7 +674,7 @@ final class ClassMetadata
*/
public function hasInverseAssociationMapping($mappedByFieldName)
{
return isset($this->_inverseMappings[$mappedByFieldName]);
return isset($this->inverseMappings[$mappedByFieldName]);
}
/**
......@@ -676,7 +684,7 @@ final class ClassMetadata
*/
public function getAssociationMappings()
{
return $this->_associationMappings;
return $this->associationMappings;
}
/**
......@@ -688,7 +696,7 @@ final class ClassMetadata
*/
public function getAssociations()
{
return $this->_associationMappings;
return $this->associationMappings;
}
/**
......@@ -700,8 +708,8 @@ final class ClassMetadata
*/
public function getFieldName($columnName)
{
return isset($this->_fieldNames[$columnName]) ?
$this->_fieldNames[$columnName] : $columnName;
return isset($this->fieldNames[$columnName]) ?
$this->fieldNames[$columnName] : $columnName;
}
/**
......@@ -713,8 +721,7 @@ final class ClassMetadata
*/
public function getFieldNameForLowerColumnName($lcColumnName)
{
return isset($this->_lcColumnToFieldNames[$lcColumnName]) ?
$this->_lcColumnToFieldNames[$lcColumnName] : $lcColumnName;
return $this->lcColumnToFieldNames[$lcColumnName];
}
/**
......@@ -725,7 +732,7 @@ final class ClassMetadata
*/
public function hasLowerColumn($lcColumnName)
{
return isset($this->_lcColumnToFieldNames[$lcColumnName]);
return isset($this->lcColumnToFieldNames[$lcColumnName]);
}
/**
......@@ -744,35 +751,31 @@ final class ClassMetadata
throw MappingException::missingType();
}
/*if ( ! is_object($mapping['type'])) {
$mapping['type'] = \Doctrine\DBAL\Types\Type::getType($mapping['type']);
}*/
// Complete fieldName and columnName mapping
if ( ! isset($mapping['columnName'])) {
$mapping['columnName'] = $mapping['fieldName'];
}
$lcColumnName = strtolower($mapping['columnName']);
$this->_columnNames[$mapping['fieldName']] = $mapping['columnName'];
$this->_fieldNames[$mapping['columnName']] = $mapping['fieldName'];
$this->_lcColumnToFieldNames[$lcColumnName] = $mapping['fieldName'];
$this->columnNames[$mapping['fieldName']] = $mapping['columnName'];
$this->fieldNames[$mapping['columnName']] = $mapping['fieldName'];
$this->lcColumnToFieldNames[$lcColumnName] = $mapping['fieldName'];
// Complete id mapping
if (isset($mapping['id']) && $mapping['id'] === true) {
if ( ! in_array($mapping['fieldName'], $this->_identifier)) {
$this->_identifier[] = $mapping['fieldName'];
if ( ! in_array($mapping['fieldName'], $this->identifier)) {
$this->identifier[] = $mapping['fieldName'];
}
// Check for composite key
if ( ! $this->_isIdentifierComposite && count($this->_identifier) > 1) {
$this->_isIdentifierComposite = true;
if ( ! $this->isIdentifierComposite && count($this->identifier) > 1) {
$this->isIdentifierComposite = true;
}
}
// Store ReflectionProperty of mapped field
$refProp = $this->_reflectionClass->getProperty($mapping['fieldName']);
$refProp = $this->reflClass->getProperty($mapping['fieldName']);
$refProp->setAccessible(true);
$this->_reflectionProperties[$mapping['fieldName']] = $refProp;
$this->reflFields[$mapping['fieldName']] = $refProp;
}
/**
......@@ -814,7 +817,7 @@ final class ClassMetadata
*/
public function getIdentifier()
{
return $this->_identifier;
return $this->identifier;
}
/**
......@@ -824,7 +827,7 @@ final class ClassMetadata
*/
public function getIdentifierFieldNames()
{
return $this->_identifier;
return $this->identifier;
}
/**
......@@ -835,11 +838,11 @@ final class ClassMetadata
*/
public function getSingleIdentifierFieldName()
{
if ($this->_isIdentifierComposite) {
if ($this->isIdentifierComposite) {
throw DoctrineException::updateMe("Calling getSingleIdentifierFieldName "
. "on a class that uses a composite identifier is not allowed.");
}
return $this->_identifier[0];
return $this->identifier[0];
}
/**
......@@ -862,7 +865,7 @@ final class ClassMetadata
*/
public function setIdentifier(array $identifier)
{
$this->_identifier = $identifier;
$this->identifier = $identifier;
}
/**
......@@ -872,23 +875,9 @@ final class ClassMetadata
*/
public function hasField($fieldName)
{
return isset($this->_reflectionProperties[$fieldName]);
return isset($this->reflFields[$fieldName]);
}
/**
* Sets the value of a field on an entity of the mapped class.
*
* @param object $entity
* @param string $field
* @param mixed $value
*/
/*public function setValue($entity, $field, $value)
{
if (isset($this->_reflectionProperties[$field])) {
$this->_reflectionProperties[$field]->setValue($entity, $value);
}
}*/
/**
* Extracts the identifier values of an entity of this class.
*
......@@ -897,17 +886,17 @@ final class ClassMetadata
*/
public function getIdentifierValues($entity)
{
if ($this->_isIdentifierComposite) {
if ($this->isIdentifierComposite) {
$id = array();
foreach ($this->_identifier as $idField) {
$value = $this->_reflectionProperties[$idField]->getValue($entity);
foreach ($this->identifier as $idField) {
$value = $this->reflFields[$idField]->getValue($entity);
if ($value !== null) {
$id[] = $value;
}
}
return $id;
} else {
return $this->_reflectionProperties[$this->_identifier[0]]->getValue($entity);
return $this->reflFields[$this->identifier[0]]->getValue($entity);
}
}
......@@ -920,12 +909,12 @@ final class ClassMetadata
*/
public function setIdentifierValues($entity, $id)
{
if ($this->_isIdentifierComposite) {
if ($this->isIdentifierComposite) {
foreach ((array)$id as $idField => $idValue) {
$this->_reflectionProperties[$idField]->setValue($entity, $idValue);
$this->reflFields[$idField]->setValue($entity, $idValue);
}
} else {
$this->_reflectionProperties[$this->_identifier[0]]->setValue($entity, $id);
$this->reflFields[$this->identifier[0]]->setValue($entity, $id);
}
}
......@@ -938,7 +927,7 @@ final class ClassMetadata
*/
public function setFieldValue($entity, $field, $value)
{
$this->_reflectionProperties[$field]->setValue($entity, $value);
$this->reflFields[$field]->setValue($entity, $value);
}
/**
......@@ -950,7 +939,7 @@ final class ClassMetadata
*/
public function setColumnValue($entity, $column, $value)
{
$this->_reflectionProperties[$this->_fieldNames[$column]]->setValue($entity, $value);
$this->reflFields[$this->fieldNames[$column]]->setValue($entity, $value);
}
/**
......@@ -960,7 +949,7 @@ final class ClassMetadata
*/
public function getFieldMappings()
{
return $this->_fieldMappings;
return $this->fieldMappings;
}
/**
......@@ -971,7 +960,7 @@ final class ClassMetadata
public function getColumnNames(array $fieldNames = null)
{
if ($fieldNames === null) {
return array_keys($this->_fieldNames);
return array_keys($this->fieldNames);
} else {
$columnNames = array();
foreach ($fieldNames as $fieldName) {
......@@ -998,7 +987,7 @@ final class ClassMetadata
*/
public function getFieldNames()
{
return array_values($this->_fieldNames);
return array_values($this->fieldNames);
}
/**
......@@ -1008,7 +997,7 @@ final class ClassMetadata
*/
public function getIdGeneratorType()
{
return $this->_generatorType;
return $this->generatorType;
}
/**
......@@ -1016,7 +1005,7 @@ final class ClassMetadata
*/
public function setIdGeneratorType($generatorType)
{
$this->_generatorType = $generatorType;
$this->generatorType = $generatorType;
}
/**
......@@ -1026,7 +1015,7 @@ final class ClassMetadata
*/
public function usesIdGenerator()
{
return $this->_generatorType != self::GENERATOR_TYPE_NONE;
return $this->generatorType != self::GENERATOR_TYPE_NONE;
}
/**
......@@ -1035,7 +1024,7 @@ final class ClassMetadata
*/
public function isInheritanceTypeNone()
{
return $this->_inheritanceType == self::INHERITANCE_TYPE_NONE;
return $this->inheritanceType == self::INHERITANCE_TYPE_NONE;
}
/**
......@@ -1046,7 +1035,7 @@ final class ClassMetadata
*/
public function isInheritanceTypeJoined()
{
return $this->_inheritanceType == self::INHERITANCE_TYPE_JOINED;
return $this->inheritanceType == self::INHERITANCE_TYPE_JOINED;
}
/**
......@@ -1057,7 +1046,7 @@ final class ClassMetadata
*/
public function isInheritanceTypeSingleTable()
{
return $this->_inheritanceType == self::INHERITANCE_TYPE_SINGLE_TABLE;
return $this->inheritanceType == self::INHERITANCE_TYPE_SINGLE_TABLE;
}
/**
......@@ -1068,7 +1057,7 @@ final class ClassMetadata
*/
public function isInheritanceTypeTablePerClass()
{
return $this->_inheritanceType == self::INHERITANCE_TYPE_TABLE_PER_CLASS;
return $this->inheritanceType == self::INHERITANCE_TYPE_TABLE_PER_CLASS;
}
/**
......@@ -1078,7 +1067,7 @@ final class ClassMetadata
*/
public function isIdGeneratorIdentity()
{
return $this->_generatorType == self::GENERATOR_TYPE_IDENTITY;
return $this->generatorType == self::GENERATOR_TYPE_IDENTITY;
}
/**
......@@ -1088,7 +1077,7 @@ final class ClassMetadata
*/
public function isIdGeneratorSequence()
{
return $this->_generatorType == self::GENERATOR_TYPE_SEQUENCE;
return $this->generatorType == self::GENERATOR_TYPE_SEQUENCE;
}
/**
......@@ -1098,7 +1087,7 @@ final class ClassMetadata
*/
public function isIdGeneratorTable()
{
$this->_generatorType == self::GENERATOR_TYPE_TABLE;
$this->generatorType == self::GENERATOR_TYPE_TABLE;
}
/**
......@@ -1109,7 +1098,7 @@ final class ClassMetadata
*/
public function isIdentifierNatural()
{
return $this->_generatorType == self::GENERATOR_TYPE_NONE;
return $this->generatorType == self::GENERATOR_TYPE_NONE;
}
/**
......@@ -1120,8 +1109,8 @@ final class ClassMetadata
*/
public function getTypeOfField($fieldName)
{
return isset($this->_fieldMappings[$fieldName]) ?
$this->_fieldMappings[$fieldName]['type'] : null;
return isset($this->fieldMappings[$fieldName]) ?
$this->fieldMappings[$fieldName]['type'] : null;
}
/**
......@@ -1139,7 +1128,7 @@ final class ClassMetadata
*/
public function getFieldLength($fieldName)
{
return $this->_fieldMappings[$fieldName]['length'];
return $this->fieldMappings[$fieldName]['length'];
}
/**
......@@ -1149,7 +1138,7 @@ final class ClassMetadata
*/
public function getTableName()
{
return $this->_primaryTable['name'];
return $this->primaryTable['name'];
}
public function getInheritedFields()
......@@ -1176,7 +1165,7 @@ final class ClassMetadata
*/
public function getInheritanceType()
{
return $this->_inheritanceType;
return $this->inheritanceType;
}
/**
......@@ -1189,7 +1178,7 @@ final class ClassMetadata
*/
public function setSubclasses(array $subclasses)
{
$this->_subClasses = $subclasses;
$this->subClasses = $subclasses;
}
/**
......@@ -1199,7 +1188,7 @@ final class ClassMetadata
*/
public function getSubclasses()
{
return $this->_subClasses;
return $this->subClasses;
}
/**
......@@ -1209,7 +1198,7 @@ final class ClassMetadata
*/
public function hasSubclasses()
{
return ! $this->_subClasses;
return ! $this->subClasses;
}
/**
......@@ -1219,7 +1208,7 @@ final class ClassMetadata
*/
public function getParentClasses()
{
return $this->_parentClasses;
return $this->parentClasses;
}
/**
......@@ -1229,9 +1218,9 @@ final class ClassMetadata
*/
public function setParentClasses(array $classNames)
{
$this->_parentClasses = $classNames;
$this->parentClasses = $classNames;
if (count($classNames) > 0) {
$this->_rootEntityName = array_pop($classNames);
$this->rootEntityName = array_pop($classNames);
}
}
......@@ -1242,7 +1231,7 @@ final class ClassMetadata
*/
public function hasParentClasses()
{
return ! $this->_parentClasses;
return ! $this->parentClasses;
}
/**
......@@ -1255,7 +1244,7 @@ final class ClassMetadata
if ( ! $this->_isInheritanceType($type)) {
throw MappingException::invalidInheritanceType($type);
}
$this->_inheritanceType = $type;
$this->inheritanceType = $type;
}
/**
......@@ -1265,7 +1254,7 @@ final class ClassMetadata
*/
public function isInheritedField($fieldName)
{
return isset($this->_fieldMappings[$fieldName]['inherited']);
return isset($this->fieldMappings[$fieldName]['inherited']);
}
/**
......@@ -1276,7 +1265,7 @@ final class ClassMetadata
*/
public function setTableName($tableName)
{
$this->_primaryTable['name'] = $tableName;
$this->primaryTable['name'] = $tableName;
}
/**
......@@ -1291,7 +1280,7 @@ final class ClassMetadata
*/
public function setPrimaryTable(array $primaryTableDefinition)
{
$this->_primaryTable = $primaryTableDefinition;
$this->primaryTable = $primaryTableDefinition;
}
/**
......@@ -1302,7 +1291,7 @@ final class ClassMetadata
*/
public function getPrimaryTable()
{
return $this->_primaryTable;
return $this->primaryTable;
}
/**
......@@ -1343,9 +1332,9 @@ final class ClassMetadata
*/
private function _completeAssociationMapping(array $mapping)
{
$mapping['sourceEntity'] = $this->_entityName;
$mapping['sourceEntity'] = $this->name;
if (isset($mapping['targetEntity']) && strpos($mapping['targetEntity'], '\\') === false) {
$mapping['targetEntity'] = $this->_namespace . '\\' . $mapping['targetEntity'];
$mapping['targetEntity'] = $this->namespace . '\\' . $mapping['targetEntity'];
}
return $mapping;
}
......@@ -1358,10 +1347,10 @@ final class ClassMetadata
public function mapField(array $mapping)
{
$this->_validateAndCompleteFieldMapping($mapping);
if (isset($this->_fieldMappings[$mapping['fieldName']])) {
if (isset($this->fieldMappings[$mapping['fieldName']])) {
throw MappingException::duplicateFieldMapping($mapping['fieldName']);
}
$this->_fieldMappings[$mapping['fieldName']] = $mapping;
$this->fieldMappings[$mapping['fieldName']] = $mapping;
}
/**
......@@ -1385,7 +1374,7 @@ final class ClassMetadata
*/
public function addFieldMapping(array $fieldMapping)
{
$this->_fieldMappings[$fieldMapping['fieldName']] = $fieldMapping;
$this->fieldMappings[$fieldMapping['fieldName']] = $fieldMapping;
}
/**
......@@ -1410,7 +1399,7 @@ final class ClassMetadata
private function _registerMappingIfInverse(AssociationMapping $assoc)
{
if ($assoc->isInverseSide()) {
$this->_inverseMappings[$assoc->getMappedByFieldName()] = $assoc;
$this->inverseMappings[$assoc->getMappedByFieldName()] = $assoc;
}
}
......@@ -1457,16 +1446,16 @@ final class ClassMetadata
private function _storeAssociationMapping(AssociationMapping $assocMapping)
{
$sourceFieldName = $assocMapping->getSourceFieldName();
if (isset($this->_associationMappings[$sourceFieldName])) {
if (isset($this->associationMappings[$sourceFieldName])) {
throw MappingException::duplicateFieldMapping();
}
$this->_associationMappings[$sourceFieldName] = $assocMapping;
$this->associationMappings[$sourceFieldName] = $assocMapping;
$this->_registerMappingIfInverse($assocMapping);
// Store ReflectionProperty of mapped field
$refProp = $this->_reflectionClass->getProperty($sourceFieldName);
$refProp = $this->reflClass->getProperty($sourceFieldName);
$refProp->setAccessible(true);
$this->_reflectionProperties[$sourceFieldName] = $refProp;
$this->reflFields[$sourceFieldName] = $refProp;
}
/**
......@@ -1476,7 +1465,7 @@ final class ClassMetadata
*/
public function setCustomRepositoryClass($repositoryClassName)
{
$this->_customRepositoryClassName = $repositoryClassName;
$this->customRepositoryClassName = $repositoryClassName;
}
/**
......@@ -1487,7 +1476,7 @@ final class ClassMetadata
*/
public function getCustomRepositoryClass()
{
return $this->_customRepositoryClassName;
return $this->customRepositoryClassName;
}
/**
......@@ -1502,7 +1491,7 @@ final class ClassMetadata
*/
public function setJoinSubClasses($bool)
{
$this->_joinSubclasses = (bool)$bool;
$this->joinSubclasses = (bool)$bool;
}
/**
......@@ -1514,7 +1503,7 @@ final class ClassMetadata
*/
public function getJoinSubClasses()
{
return $this->_joinSubclasses;
return $this->joinSubclasses;
}
/**
......@@ -1530,10 +1519,10 @@ final class ClassMetadata
$entity->$callback();
}
foreach ($this->getLifecycleListeners($lifecycleEvent) as $className => $callback) {
if ( ! isset($this->_lifecycleListenerInstances[$className])) {
$this->_lifecycleListenerInstances[$className] = new $className;
if ( ! isset($this->lifecycleListenerInstances[$className])) {
$this->lifecycleListenerInstances[$className] = new $className;
}
$this->_lifecycleListenerInstances[$className]->$callback($entity);
$this->lifecycleListenerInstances[$className]->$callback($entity);
}
}
......@@ -1545,8 +1534,8 @@ final class ClassMetadata
*/
public function getLifecycleCallbacks($event)
{
return isset($this->_lifecycleCallbacks[$event]) ?
$this->_lifecycleCallbacks[$event] : array();
return isset($this->lifecycleCallbacks[$event]) ?
$this->lifecycleCallbacks[$event] : array();
}
/**
......@@ -1557,8 +1546,8 @@ final class ClassMetadata
*/
public function getLifecycleListeners($event)
{
return isset($this->_lifecycleListeners[$event]) ?
$this->_lifecycleListeners[$event] : array();
return isset($this->lifecycleListeners[$event]) ?
$this->lifecycleListeners[$event] : array();
}
/**
......@@ -1572,9 +1561,9 @@ final class ClassMetadata
*/
public function addLifecycleListener($listenerClass, array $callbacks)
{
$this->_lifecycleListeners[$event][$listenerClass] = array();
$this->lifecycleListeners[$event][$listenerClass] = array();
foreach ($callbacks as $method => $event) {
$this->_lifecycleListeners[$event][$listenerClass][] = $method;
$this->lifecycleListeners[$event][$listenerClass][] = $method;
}
}
......@@ -1589,11 +1578,11 @@ final class ClassMetadata
*/
public function addLifecycleCallback($callback, $event)
{
if ( ! isset($this->_lifecycleCallbacks[$event])) {
$this->_lifecycleCallbacks[$event] = array();
if ( ! isset($this->lifecycleCallbacks[$event])) {
$this->lifecycleCallbacks[$event] = array();
}
if ( ! in_array($callback, $this->_lifecycleCallbacks[$event])) {
$this->_lifecycleCallbacks[$event][$callback] = $callback;
if ( ! in_array($callback, $this->lifecycleCallbacks[$event])) {
$this->lifecycleCallbacks[$event][$callback] = $callback;
}
}
......@@ -1605,7 +1594,7 @@ final class ClassMetadata
*/
public function setDiscriminatorColumn($columnDef)
{
$this->_discriminatorColumn = $columnDef;
$this->discriminatorColumn = $columnDef;
}
/**
......@@ -1623,7 +1612,7 @@ final class ClassMetadata
*/
public function getDiscriminatorColumn()
{
return $this->_discriminatorColumn;
return $this->discriminatorColumn;
}
/**
......@@ -1634,7 +1623,7 @@ final class ClassMetadata
*/
public function setDiscriminatorValue($value)
{
$this->_discriminatorValue = $value;
$this->discriminatorValue = $value;
}
/**
......@@ -1645,7 +1634,7 @@ final class ClassMetadata
*/
public function getDiscriminatorValue()
{
return $this->_discriminatorValue;
return $this->discriminatorValue;
}
/**
......@@ -1656,7 +1645,7 @@ final class ClassMetadata
*/
public function isDiscriminatorColumn($columnName)
{
return $columnName === $this->_discriminatorColumn['name'];
return $columnName === $this->discriminatorColumn['name'];
}
/**
......@@ -1667,7 +1656,7 @@ final class ClassMetadata
*/
public function hasAssociation($fieldName)
{
return isset($this->_associationMappings[$fieldName]);
return isset($this->associationMappings[$fieldName]);
}
/**
......@@ -1679,8 +1668,8 @@ final class ClassMetadata
*/
public function isSingleValuedAssociation($fieldName)
{
return isset($this->_associationMappings[$fieldName]) &&
$this->_associationMappings[$fieldName]->isOneToOne();
return isset($this->associationMappings[$fieldName]) &&
$this->associationMappings[$fieldName]->isOneToOne();
}
/**
......@@ -1692,8 +1681,8 @@ final class ClassMetadata
*/
public function isCollectionValuedAssociation($fieldName)
{
return isset($this->_associationMappings[$fieldName]) &&
! $this->_associationMappings[$fieldName]->isOneToOne();
return isset($this->associationMappings[$fieldName]) &&
! $this->associationMappings[$fieldName]->isOneToOne();
}
/**
......@@ -1705,7 +1694,7 @@ final class ClassMetadata
*/
/*public function getIdGeneratorName()
{
return $this->_idGeneratorName;
return $this->idGeneratorName;
}*/
/**
......@@ -1715,7 +1704,7 @@ final class ClassMetadata
*/
public function setIdGenerator($generator)
{
$this->_idGenerator = $generator;
$this->idGenerator = $generator;
}
/**
......@@ -1725,7 +1714,7 @@ final class ClassMetadata
*/
public function getIdGenerator()
{
return $this->_idGenerator;
return $this->idGenerator;
}
/**
......@@ -1745,7 +1734,7 @@ final class ClassMetadata
*/
public function getSequenceGeneratorDefinition()
{
return $this->_sequenceGeneratorDefinition;
return $this->sequenceGeneratorDefinition;
}
/**
......@@ -1764,7 +1753,7 @@ final class ClassMetadata
*/
public function setSequenceGeneratorDefinition(array $definition)
{
$this->_sequenceGeneratorDefinition = $definition;
$this->sequenceGeneratorDefinition = $definition;
}
/**
......
......@@ -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();
......
......@@ -339,8 +339,8 @@ class UnitOfWork implements PropertyChangedListener
if ($this->getEntityState($entity) == self::STATE_MANAGED) {
$this->_computeEntityChanges($class, $entity);
// Look for changes in associations of the entity
foreach ($class->getAssociationMappings() as $assoc) {
$val = $class->getReflectionProperty($assoc->getSourceFieldName())->getValue($entity);
foreach ($class->associationMappings as $assoc) {
$val = $class->reflFields[$assoc->getSourceFieldName()]->getValue($entity);
if ($val !== null) {
$this->_computeAssociationChanges($assoc, $val);
}
......@@ -406,7 +406,7 @@ class UnitOfWork implements PropertyChangedListener
if ( ! $coll->isEmpty()) {
$coll->setDirty(true);
}
$class->getReflectionProperty($name)->setValue($entity, $coll);
$class->reflFields[$name]->setValue($entity, $coll);
$actualData[$name] = $coll;
}
}
......@@ -541,7 +541,7 @@ class UnitOfWork implements PropertyChangedListener
// $persister->executeInserts() at the end to allow easy prepared
// statement reuse and maybe bulk operations in the persister.
// Same for update/delete.
$className = $class->getClassName();
$className = $class->name;
$persister = $this->getEntityPersister($className);
foreach ($this->_entityInsertions as $entity) {
if (get_class($entity) == $className) {
......@@ -550,7 +550,7 @@ class UnitOfWork implements PropertyChangedListener
// Persister returned a post-insert ID
$oid = spl_object_hash($entity);
$idField = $class->getSingleIdentifierFieldName();
$class->getReflectionProperty($idField)->setValue($entity, $returnVal);
$class->reflFields[$idField]->setValue($entity, $returnVal);
$this->_entityIdentifiers[$oid] = array($returnVal);
$this->_entityStates[$oid] = self::STATE_MANAGED;
$this->_originalEntityData[$oid][$idField] = $returnVal;
......@@ -567,7 +567,7 @@ class UnitOfWork implements PropertyChangedListener
*/
private function _executeUpdates($class)
{
$className = $class->getClassName();
$className = $class->name;
$persister = $this->getEntityPersister($className);
foreach ($this->_entityUpdates as $entity) {
if (get_class($entity) == $className) {
......@@ -583,7 +583,7 @@ class UnitOfWork implements PropertyChangedListener
*/
private function _executeDeletions($class)
{
$className = $class->getClassName();
$className = $class->name;
$persister = $this->getEntityPersister($className);
foreach ($this->_entityDeletions as $entity) {
if (get_class($entity) == $className) {
......@@ -626,11 +626,11 @@ class UnitOfWork implements PropertyChangedListener
// Calculate dependencies for new nodes
foreach ($newNodes as $node) {
$class = $node->getClass();
foreach ($class->getAssociationMappings() as $assocMapping) {
foreach ($class->associationMappings as $assocMapping) {
//TODO: should skip target classes that are not in the changeset.
if ($assocMapping->isOwningSide()) {
$targetClass = $this->_em->getClassMetadata($assocMapping->getTargetEntityName());
$targetClassName = $targetClass->getClassName();
$targetClassName = $targetClass->name;
// If the target class does not yet have a node, create it
if ( ! $this->_commitOrderCalculator->hasNodeWithKey($targetClassName)) {
$this->_commitOrderCalculator->addNodeWithItem(
......@@ -838,7 +838,7 @@ class UnitOfWork implements PropertyChangedListener
throw DoctrineException::updateMe("Entity with oid '" . spl_object_hash($entity)
. "' has no identity and therefore can't be added to the identity map.");
}
$className = $classMetadata->getRootClassName();
$className = $classMetadata->rootEntityName;
if (isset($this->_identityMap[$className][$idHash])) {
return false;
}
......@@ -891,7 +891,7 @@ class UnitOfWork implements PropertyChangedListener
throw DoctrineException::updateMe("Entity with oid '" . spl_object_hash($entity)
. "' has no identity and therefore can't be removed from the identity map.");
}
$className = $classMetadata->getRootClassName();
$className = $classMetadata->rootEntityName;
if (isset($this->_identityMap[$className][$idHash])) {
unset($this->_identityMap[$className][$idHash]);
$this->_entityStates[$oid] = self::STATE_DETACHED;
......@@ -949,7 +949,7 @@ class UnitOfWork implements PropertyChangedListener
}
return isset($this->_identityMap
[$classMetadata->getRootClassName()]
[$classMetadata->rootEntityName]
[$idHash]
);
}
......@@ -1125,13 +1125,13 @@ class UnitOfWork implements PropertyChangedListener
throw new InvalidArgumentException('New entity passed to merge().');
}
$managedCopy = $this->tryGetById($id, $class->getRootClassName());
$managedCopy = $this->tryGetById($id, $class->rootEntityName);
if ($managedCopy) {
if ($this->getEntityState($managedCopy) == self::STATE_DELETED) {
throw new InvalidArgumentException('Can not merge with a deleted entity.');
}
} else {
$managedCopy = $this->_em->find($class->getClassName(), $id);
$managedCopy = $this->_em->find($class->name, $id);
}
// Merge state of $entity into existing (managed) entity
......@@ -1151,9 +1151,9 @@ class UnitOfWork implements PropertyChangedListener
$assocField = $assoc->getSourceFieldName();
$prevClass = $this->_em->getClassMetadata(get_class($prevManagedCopy));
if ($assoc->isOneToOne()) {
$prevClass->getReflectionProperty($assocField)->setValue($prevManagedCopy, $managedCopy);
$prevClass->reflFields[$assocField]->setValue($prevManagedCopy, $managedCopy);
} else {
$prevClass->getReflectionProperty($assocField)->getValue($prevManagedCopy)->add($managedCopy);
$prevClass->reflFields[$assocField]->getValue($prevManagedCopy)->add($managedCopy);
}
}
......@@ -1168,11 +1168,11 @@ class UnitOfWork implements PropertyChangedListener
private function _cascadeMerge($entity, $managedCopy, array &$visited)
{
$class = $this->_em->getClassMetadata(get_class($entity));
foreach ($class->getAssociationMappings() as $assocMapping) {
foreach ($class->associationMappings as $assocMapping) {
if ( ! $assocMapping->isCascadeMerge()) {
continue;
}
$relatedEntities = $class->getReflectionProperty($assocMapping->getSourceFieldName())
$relatedEntities = $class->reflFields[$assocMapping->getSourceFieldName()]
->getValue($entity);
if (($relatedEntities instanceof Collection) && count($relatedEntities) > 0) {
foreach ($relatedEntities as $relatedEntity) {
......@@ -1193,11 +1193,11 @@ class UnitOfWork implements PropertyChangedListener
private function _cascadeSave($entity, array &$visited, array &$insertNow)
{
$class = $this->_em->getClassMetadata(get_class($entity));
foreach ($class->getAssociationMappings() as $assocMapping) {
foreach ($class->associationMappings as $assocMapping) {
if ( ! $assocMapping->isCascadeSave()) {
continue;
}
$relatedEntities = $class->getReflectionProperty($assocMapping->getSourceFieldName())
$relatedEntities = $class->reflFields[$assocMapping->getSourceFieldName()]
->getValue($entity);
if (($relatedEntities instanceof Collection || is_array($relatedEntities))
&& count($relatedEntities) > 0) {
......@@ -1218,11 +1218,11 @@ class UnitOfWork implements PropertyChangedListener
private function _cascadeDelete($entity, array &$visited)
{
$class = $this->_em->getClassMetadata(get_class($entity));
foreach ($class->getAssociationMappings() as $assocMapping) {
foreach ($class->associationMappings as $assocMapping) {
if ( ! $assocMapping->isCascadeDelete()) {
continue;
}
$relatedEntities = $class->getReflectionProperty($assocMapping->getSourceFieldName())
$relatedEntities = $class->reflFields[$assocMapping->getSourceFieldName()]
->getValue($entity);
if ($relatedEntities instanceof Collection || is_array($relatedEntities)
&& count($relatedEntities) > 0) {
......@@ -1312,7 +1312,7 @@ class UnitOfWork implements PropertyChangedListener
$id = array();
if ($class->isIdentifierComposite()) {
$identifierFieldNames = $class->getIdentifier();
$identifierFieldNames = $class->identifier;
foreach ($identifierFieldNames as $fieldName) {
$id[] = $data[$fieldName];
}
......@@ -1321,7 +1321,7 @@ class UnitOfWork implements PropertyChangedListener
$id = array($data[$class->getSingleIdentifierFieldName()]);
$idHash = $id[0];
}
$entity = $this->tryGetByIdHash($idHash, $class->getRootClassName());
$entity = $this->tryGetByIdHash($idHash, $class->rootEntityName);
if ($entity) {
$oid = spl_object_hash($entity);
$overrideLocalChanges = false;
......@@ -1338,17 +1338,17 @@ class UnitOfWork implements PropertyChangedListener
if ($overrideLocalChanges) {
foreach ($data as $field => $value) {
if ($class->hasField($field)) {
$class->setFieldValue($entity, $field, $value);
if (isset($class->reflFields[$field])) {
$class->reflFields[$field]->setValue($entity, $value);
}
}
} else {
foreach ($data as $field => $value) {
if ($class->hasField($field)) {
$currentValue = $class->getReflectionProperty($field)->getValue($entity);
if (isset($class->reflFields[$field])) {
$currentValue = $class->reflFields[$field]->getValue($entity);
if ( ! isset($this->_originalEntityData[$oid][$field]) ||
$currentValue == $this->_originalEntityData[$oid][$field]) {
$class->getReflectionProperty($field)->setValue($entity, $value);
$class->reflFields[$field]->setValue($entity, $value);
}
}
}
......@@ -1437,7 +1437,7 @@ class UnitOfWork implements PropertyChangedListener
*/
public function scheduleForDirtyCheck($entity)
{
$rootClassName = $this->_em->getClassMetadata(get_class($entity))->getRootClassName();
$rootClassName = $this->_em->getClassMetadata(get_class($entity))->rootEntityName;
$this->_scheduledForDirtyCheck[$rootClassName] = $entity;
}
......
......@@ -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