From 2a99d5a19bda121eac12c0832ac9f87b6d750b75 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 16 Feb 2015 01:02:56 +0000 Subject: [PATCH] #1113 - minor CS fixes (spacing/alignment) --- .../Entity/BasicEntityPersister.php | 29 +++++++++++++------ lib/Doctrine/ORM/UnitOfWork.php | 4 ++- .../ORM/Utility/IdentifierFlattener.php | 3 ++ lib/Doctrine/ORM/Utility/PersisterHelper.php | 4 ++- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index a1d1969a8..5d096a9dc 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -1649,16 +1649,19 @@ class BasicEntityPersister implements EntityPersister $association = $this->class->associationMappings[$field]; // Many-To-Many requires join table check for joinColumn $columns = array(); - $class = $this->class; + $class = $this->class; + if ($association['type'] === ClassMetadata::MANY_TO_MANY) { if ( ! $association['isOwningSide']) { $association = $assoc; } - $joinColumns = $assoc['isOwningSide'] + + $joinTableName = $this->quoteStrategy->getJoinTableName($association, $class, $this->platform); + $joinColumns = $assoc['isOwningSide'] ? $association['joinTable']['joinColumns'] : $association['joinTable']['inverseJoinColumns']; - $joinTableName = $this->quoteStrategy->getJoinTableName($association, $class, $this->platform); + foreach ($joinColumns as $joinColumn) { $columns[] = $joinTableName . '.' . $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); } @@ -1691,7 +1694,6 @@ class BasicEntityPersister implements EntityPersister throw ORMException::unrecognizedField($field); } - /** * Gets the conditional SQL fragment used in the WHERE clause when selecting * entities in this persister. @@ -1812,6 +1814,7 @@ class BasicEntityPersister implements EntityPersister $types = array_merge($types, $this->getTypes($field, $value, $this->class)); $params = array_merge($params, $this->getValues($value)); } + return array($params, $types); } @@ -1840,6 +1843,7 @@ class BasicEntityPersister implements EntityPersister $types = array_merge($types, $this->getTypes($criterion['field'], $criterion['value'], $criterion['class'])); $params = array_merge($params, $this->getValues($criterion['value'])); } + return array($params, $types); } @@ -1861,10 +1865,12 @@ class BasicEntityPersister implements EntityPersister case (isset($class->fieldMappings[$field])): $types = array_merge($types, PersisterHelper::getTypeOfField($field, $class, $this->em)); break; + case (isset($class->associationMappings[$field])): $assoc = $class->associationMappings[$field]; $class = $this->em->getClassMetadata($assoc['targetEntity']); - if (!$assoc['isOwningSide']) { + + if (! $assoc['isOwningSide']) { $assoc = $class->associationMappings[$assoc['mappedBy']]; $class = $this->em->getClassMetadata($assoc['targetEntity']); } @@ -1872,6 +1878,7 @@ class BasicEntityPersister implements EntityPersister $columns = $assoc['type'] === ClassMetadata::MANY_TO_MANY ? $assoc['relationToTargetKeyColumns'] : $assoc['sourceToTargetKeyColumns']; + foreach ($columns as $column){ $types[] = PersisterHelper::getTypeOfColumn($column, $class, $this->em); } @@ -1883,11 +1890,14 @@ class BasicEntityPersister implements EntityPersister } if (is_array($value)) { - $types = array_map(function ($type) { - $type = Type::getType($type)->getBindingType(); - return $type + Connection::ARRAY_PARAM_OFFSET; - }, $types); + return array_map( + function ($type) { + return Type::getType($type)->getBindingType() + Connection::ARRAY_PARAM_OFFSET; + }, + $types + ); } + return $types; } @@ -1914,6 +1924,7 @@ class BasicEntityPersister implements EntityPersister $class = $this->em->getClassMetadata(get_class($value)); if ($class->isIdentifierComposite) { $newValue = array(); + foreach ($class->getIdentifierValues($value) as $innerValue) { $newValue = array_merge($newValue, $this->getValues($innerValue)); } diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index ff4752bdd..c976443a8 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2629,7 +2629,9 @@ class UnitOfWork implements PropertyChangedListener } else { $associatedId[$targetClass->fieldNames[$targetColumn]] = $joinColumnValue; } - } elseif ($targetClass->containsForeignIdentifier && in_array($targetClass->getFieldForColumn($targetColumn), $targetClass->identifier, true)) { + } elseif ($targetClass->containsForeignIdentifier + && in_array($targetClass->getFieldForColumn($targetColumn), $targetClass->identifier, true) + ) { // the missing key is part of target's entity primary key $associatedId = array(); break; diff --git a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php index 7c9e488e5..4a58dfeda 100644 --- a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php +++ b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php @@ -73,6 +73,7 @@ final class IdentifierFlattener foreach ($class->identifier as $field) { if (isset($class->associationMappings[$field]) && isset($id[$field]) && is_object($id[$field])) { + /* @var $targetClassMetadata ClassMetadata */ $targetClassMetadata = $this->metadataFactory->getMetadataFor( $class->associationMappings[$field]['targetEntity'] ); @@ -86,9 +87,11 @@ final class IdentifierFlattener $flatId[$field] = implode(' ', $associatedId); } elseif (isset($class->associationMappings[$field])) { $associatedId = array(); + foreach ($class->associationMappings[$field]['joinColumns'] as $joinColumn) { $associatedId[] = $id[$joinColumn['name']]; } + $flatId[$field] = implode(' ', $associatedId); } else { $flatId[$field] = $id[$field]; diff --git a/lib/Doctrine/ORM/Utility/PersisterHelper.php b/lib/Doctrine/ORM/Utility/PersisterHelper.php index 888d17d13..6fe7545ea 100644 --- a/lib/Doctrine/ORM/Utility/PersisterHelper.php +++ b/lib/Doctrine/ORM/Utility/PersisterHelper.php @@ -66,11 +66,13 @@ class PersisterHelper $joinData = $assoc; } - $types = array(); + $types = array(); $targetClass = $em->getClassMetadata($assoc['targetEntity']); + foreach ($joinData['joinColumns'] as $joinColumn) { $types[] = self::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $em); } + return $types; }