1
0
Fork 0
mirror of synced 2025-04-01 12:26:11 +03:00

Simplified ClassMetadata lookup in UnitOfWork and added docblock.

This commit is contained in:
Roman S. Borschel 2010-08-09 21:44:52 +02:00
parent 5178f4b7d6
commit 4826739824
2 changed files with 11 additions and 21 deletions

View file

@ -1172,22 +1172,6 @@ class ClassMetadataInfo
$type == self::INHERITANCE_TYPE_TABLE_PER_CLASS;
}
/**
* Makes some automatic additions to the association mapping to make the life
* easier for the user, and store join columns in the metadata.
*
* @param array $mapping
* @todo Pass param by ref?
*/
/*private function _completeAssociationMapping(array $mapping)
{
$mapping['sourceEntity'] = $this->name;
if (isset($mapping['targetEntity']) && strpos($mapping['targetEntity'], '\\') === false && strlen($this->namespace) > 0) {
$mapping['targetEntity'] = $this->namespace . '\\' . $mapping['targetEntity'];
}
return $mapping;
}*/
/**
* Adds a mapped field to the class.
*

View file

@ -389,7 +389,7 @@ class UnitOfWork implements PropertyChangedListener
* @param ClassMetadata $class The class descriptor of the entity.
* @param object $entity The entity for which to compute the changes.
*/
public function computeChangeSet(Mapping\ClassMetadata $class, $entity)
public function computeChangeSet(ClassMetadata $class, $entity)
{
if ( ! $class->isInheritanceTypeNone()) {
$class = $this->em->getClassMetadata(get_class($entity));
@ -1901,11 +1901,10 @@ class UnitOfWork implements PropertyChangedListener
} else {
if ($targetClass->subClasses) {
// If it might be a subtype, it can not be lazy
//$newValue = $assoc->load($entity, null, $this->em, $associatedId);
$newValue = $this->getEntityPersister($assoc['targetEntity'])
->loadOneToOneEntity($assoc, $entity, null, $associatedId);
} else {
if ($assoc['fetch'] == Mapping\ClassMetadata::FETCH_EAGER) {
if ($assoc['fetch'] == ClassMetadata::FETCH_EAGER) {
// TODO: Maybe it could be optimized to do an eager fetch with a JOIN inside
// the persister instead of this rather unperformant approach.
$newValue = $this->em->find($assoc['targetEntity'], $associatedId);
@ -1938,10 +1937,9 @@ class UnitOfWork implements PropertyChangedListener
);
$pColl->setOwner($entity, $assoc);
$reflField->setValue($entity, $pColl);
if ($assoc['fetch'] == Mapping\ClassMetadata::FETCH_LAZY) {
if ($assoc['fetch'] == ClassMetadata::FETCH_LAZY) {
$pColl->setInitialized(false);
} else {
//$assoc->load($entity, $pColl, $this->em);
$this->loadCollection($assoc, $entity, $pColl);
}
$this->originalEntityData[$oid][$field] = $pColl;
@ -1961,6 +1959,14 @@ class UnitOfWork implements PropertyChangedListener
return $entity;
}
/**
* Initializes (loads) an associated collection of an entity.
*
* @param array $assoc The association mapping.
* @param object $sourceEntity The entity that "owns" the collection.
* @param PeristentCollection $targetCollection The collection to initialize.
* @todo Maybe later move to EntityManager#initialize($proxyOrCollection). See DDC-733.
*/
public function loadCollection(array $assoc, $sourceEntity, $targetCollection)
{
switch ($assoc['type']) {