Quick optimizations are always good.
This commit is contained in:
parent
e0fc09994c
commit
b98280a504
@ -705,15 +705,17 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
|
|
||||||
foreach ($unwrappedValue as $key => $entry) {
|
foreach ($unwrappedValue as $key => $entry) {
|
||||||
$state = $this->getEntityState($entry, self::STATE_NEW);
|
$state = $this->getEntityState($entry, self::STATE_NEW);
|
||||||
$oid = spl_object_hash($entry);
|
|
||||||
|
|
||||||
if (!($entry instanceof $assoc['targetEntity'])) {
|
if ( ! ($entry instanceof $assoc['targetEntity'])) {
|
||||||
throw new ORMException(sprintf("Found entity of type %s on association %s#%s, but expecting %s",
|
throw new ORMException(
|
||||||
get_class($entry),
|
sprintf(
|
||||||
$assoc['sourceEntity'],
|
'Found entity of type %s on association %s#%s, but expecting %s',
|
||||||
$assoc['fieldName'],
|
get_class($entry),
|
||||||
$targetClass->name
|
$assoc['sourceEntity'],
|
||||||
));
|
$assoc['fieldName'],
|
||||||
|
$targetClass->name
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($state) {
|
switch ($state) {
|
||||||
@ -1010,7 +1012,7 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
// are not yet available.
|
// are not yet available.
|
||||||
$newNodes = array();
|
$newNodes = array();
|
||||||
|
|
||||||
foreach ($entityChangeSet as $oid => $entity) {
|
foreach ($entityChangeSet as $entity) {
|
||||||
$className = get_class($entity);
|
$className = get_class($entity);
|
||||||
|
|
||||||
if ($calc->hasClass($className)) {
|
if ($calc->hasClass($className)) {
|
||||||
@ -1656,7 +1658,8 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
foreach ($id as $idField => $idValue) {
|
foreach ($id as $idField => $idValue) {
|
||||||
if (isset($class->associationMappings[$idField])) {
|
if (isset($class->associationMappings[$idField])) {
|
||||||
$targetClassMetadata = $this->em->getClassMetadata($class->associationMappings[$idField]['targetEntity']);
|
$targetClassMetadata = $this->em->getClassMetadata($class->associationMappings[$idField]['targetEntity']);
|
||||||
$associatedId = $this->getEntityIdentifier($idValue);
|
$associatedId = $this->getEntityIdentifier($idValue);
|
||||||
|
|
||||||
$flatId[$idField] = $associatedId[$targetClassMetadata->identifier[0]];
|
$flatId[$idField] = $associatedId[$targetClassMetadata->identifier[0]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2418,9 +2421,9 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
case (isset($this->identityMap[$targetClass->rootEntityName][$relatedIdHash])):
|
case (isset($this->identityMap[$targetClass->rootEntityName][$relatedIdHash])):
|
||||||
$newValue = $this->identityMap[$targetClass->rootEntityName][$relatedIdHash];
|
$newValue = $this->identityMap[$targetClass->rootEntityName][$relatedIdHash];
|
||||||
|
|
||||||
// if this is an uninitialized proxy, we are deferring eager loads,
|
// If this is an uninitialized proxy, we are deferring eager loads,
|
||||||
// this association is marked as eager fetch, and its an uninitialized proxy (wtf!)
|
// this association is marked as eager fetch, and its an uninitialized proxy (wtf!)
|
||||||
// then we cann append this entity for eager loading!
|
// then we can append this entity for eager loading!
|
||||||
if ($hints['fetchMode'][$class->name][$field] == ClassMetadata::FETCH_EAGER &&
|
if ($hints['fetchMode'][$class->name][$field] == ClassMetadata::FETCH_EAGER &&
|
||||||
isset($hints['deferEagerLoad']) &&
|
isset($hints['deferEagerLoad']) &&
|
||||||
!$targetClass->isIdentifierComposite &&
|
!$targetClass->isIdentifierComposite &&
|
||||||
@ -2515,13 +2518,13 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
$this->eagerLoadingEntities = array();
|
$this->eagerLoadingEntities = array();
|
||||||
|
|
||||||
foreach ($eagerLoadingEntities as $entityName => $ids) {
|
foreach ($eagerLoadingEntities as $entityName => $ids) {
|
||||||
|
if ( ! $ids) continue;
|
||||||
|
|
||||||
$class = $this->em->getClassMetadata($entityName);
|
$class = $this->em->getClassMetadata($entityName);
|
||||||
|
|
||||||
if ($ids) {
|
$this->getEntityPersister($entityName)->loadAll(
|
||||||
$this->getEntityPersister($entityName)->loadAll(
|
array_combine($class->identifier, array(array_values($ids)))
|
||||||
array_combine($class->identifier, array(array_values($ids)))
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2901,7 +2904,7 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
*/
|
*/
|
||||||
public function isReadOnly($object)
|
public function isReadOnly($object)
|
||||||
{
|
{
|
||||||
if ( ! is_object($object) ) {
|
if ( ! is_object($object)) {
|
||||||
throw ORMInvalidArgumentException::readOnlyRequiresManagedEntity($object);
|
throw ORMInvalidArgumentException::readOnlyRequiresManagedEntity($object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user