1
0
mirror of synced 2024-12-05 03:06:05 +03:00

#1113 - minor CS fixes (spacing/alignment)

This commit is contained in:
Marco Pivetta 2015-02-16 01:02:56 +00:00
parent 8eea7c86f7
commit 2a99d5a19b
4 changed files with 29 additions and 11 deletions

View File

@ -1649,16 +1649,19 @@ class BasicEntityPersister implements EntityPersister
$association = $this->class->associationMappings[$field]; $association = $this->class->associationMappings[$field];
// Many-To-Many requires join table check for joinColumn // Many-To-Many requires join table check for joinColumn
$columns = array(); $columns = array();
$class = $this->class; $class = $this->class;
if ($association['type'] === ClassMetadata::MANY_TO_MANY) { if ($association['type'] === ClassMetadata::MANY_TO_MANY) {
if ( ! $association['isOwningSide']) { if ( ! $association['isOwningSide']) {
$association = $assoc; $association = $assoc;
} }
$joinColumns = $assoc['isOwningSide']
$joinTableName = $this->quoteStrategy->getJoinTableName($association, $class, $this->platform);
$joinColumns = $assoc['isOwningSide']
? $association['joinTable']['joinColumns'] ? $association['joinTable']['joinColumns']
: $association['joinTable']['inverseJoinColumns']; : $association['joinTable']['inverseJoinColumns'];
$joinTableName = $this->quoteStrategy->getJoinTableName($association, $class, $this->platform);
foreach ($joinColumns as $joinColumn) { foreach ($joinColumns as $joinColumn) {
$columns[] = $joinTableName . '.' . $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform); $columns[] = $joinTableName . '.' . $this->quoteStrategy->getJoinColumnName($joinColumn, $class, $this->platform);
} }
@ -1691,7 +1694,6 @@ class BasicEntityPersister implements EntityPersister
throw ORMException::unrecognizedField($field); throw ORMException::unrecognizedField($field);
} }
/** /**
* Gets the conditional SQL fragment used in the WHERE clause when selecting * Gets the conditional SQL fragment used in the WHERE clause when selecting
* entities in this persister. * entities in this persister.
@ -1812,6 +1814,7 @@ class BasicEntityPersister implements EntityPersister
$types = array_merge($types, $this->getTypes($field, $value, $this->class)); $types = array_merge($types, $this->getTypes($field, $value, $this->class));
$params = array_merge($params, $this->getValues($value)); $params = array_merge($params, $this->getValues($value));
} }
return array($params, $types); return array($params, $types);
} }
@ -1840,6 +1843,7 @@ class BasicEntityPersister implements EntityPersister
$types = array_merge($types, $this->getTypes($criterion['field'], $criterion['value'], $criterion['class'])); $types = array_merge($types, $this->getTypes($criterion['field'], $criterion['value'], $criterion['class']));
$params = array_merge($params, $this->getValues($criterion['value'])); $params = array_merge($params, $this->getValues($criterion['value']));
} }
return array($params, $types); return array($params, $types);
} }
@ -1861,10 +1865,12 @@ class BasicEntityPersister implements EntityPersister
case (isset($class->fieldMappings[$field])): case (isset($class->fieldMappings[$field])):
$types = array_merge($types, PersisterHelper::getTypeOfField($field, $class, $this->em)); $types = array_merge($types, PersisterHelper::getTypeOfField($field, $class, $this->em));
break; break;
case (isset($class->associationMappings[$field])): case (isset($class->associationMappings[$field])):
$assoc = $class->associationMappings[$field]; $assoc = $class->associationMappings[$field];
$class = $this->em->getClassMetadata($assoc['targetEntity']); $class = $this->em->getClassMetadata($assoc['targetEntity']);
if (!$assoc['isOwningSide']) {
if (! $assoc['isOwningSide']) {
$assoc = $class->associationMappings[$assoc['mappedBy']]; $assoc = $class->associationMappings[$assoc['mappedBy']];
$class = $this->em->getClassMetadata($assoc['targetEntity']); $class = $this->em->getClassMetadata($assoc['targetEntity']);
} }
@ -1872,6 +1878,7 @@ class BasicEntityPersister implements EntityPersister
$columns = $assoc['type'] === ClassMetadata::MANY_TO_MANY $columns = $assoc['type'] === ClassMetadata::MANY_TO_MANY
? $assoc['relationToTargetKeyColumns'] ? $assoc['relationToTargetKeyColumns']
: $assoc['sourceToTargetKeyColumns']; : $assoc['sourceToTargetKeyColumns'];
foreach ($columns as $column){ foreach ($columns as $column){
$types[] = PersisterHelper::getTypeOfColumn($column, $class, $this->em); $types[] = PersisterHelper::getTypeOfColumn($column, $class, $this->em);
} }
@ -1883,11 +1890,14 @@ class BasicEntityPersister implements EntityPersister
} }
if (is_array($value)) { if (is_array($value)) {
$types = array_map(function ($type) { return array_map(
$type = Type::getType($type)->getBindingType(); function ($type) {
return $type + Connection::ARRAY_PARAM_OFFSET; return Type::getType($type)->getBindingType() + Connection::ARRAY_PARAM_OFFSET;
}, $types); },
$types
);
} }
return $types; return $types;
} }
@ -1914,6 +1924,7 @@ class BasicEntityPersister implements EntityPersister
$class = $this->em->getClassMetadata(get_class($value)); $class = $this->em->getClassMetadata(get_class($value));
if ($class->isIdentifierComposite) { if ($class->isIdentifierComposite) {
$newValue = array(); $newValue = array();
foreach ($class->getIdentifierValues($value) as $innerValue) { foreach ($class->getIdentifierValues($value) as $innerValue) {
$newValue = array_merge($newValue, $this->getValues($innerValue)); $newValue = array_merge($newValue, $this->getValues($innerValue));
} }

View File

@ -2629,7 +2629,9 @@ class UnitOfWork implements PropertyChangedListener
} else { } else {
$associatedId[$targetClass->fieldNames[$targetColumn]] = $joinColumnValue; $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 // the missing key is part of target's entity primary key
$associatedId = array(); $associatedId = array();
break; break;

View File

@ -73,6 +73,7 @@ final class IdentifierFlattener
foreach ($class->identifier as $field) { foreach ($class->identifier as $field) {
if (isset($class->associationMappings[$field]) && isset($id[$field]) && is_object($id[$field])) { if (isset($class->associationMappings[$field]) && isset($id[$field]) && is_object($id[$field])) {
/* @var $targetClassMetadata ClassMetadata */
$targetClassMetadata = $this->metadataFactory->getMetadataFor( $targetClassMetadata = $this->metadataFactory->getMetadataFor(
$class->associationMappings[$field]['targetEntity'] $class->associationMappings[$field]['targetEntity']
); );
@ -86,9 +87,11 @@ final class IdentifierFlattener
$flatId[$field] = implode(' ', $associatedId); $flatId[$field] = implode(' ', $associatedId);
} elseif (isset($class->associationMappings[$field])) { } elseif (isset($class->associationMappings[$field])) {
$associatedId = array(); $associatedId = array();
foreach ($class->associationMappings[$field]['joinColumns'] as $joinColumn) { foreach ($class->associationMappings[$field]['joinColumns'] as $joinColumn) {
$associatedId[] = $id[$joinColumn['name']]; $associatedId[] = $id[$joinColumn['name']];
} }
$flatId[$field] = implode(' ', $associatedId); $flatId[$field] = implode(' ', $associatedId);
} else { } else {
$flatId[$field] = $id[$field]; $flatId[$field] = $id[$field];

View File

@ -66,11 +66,13 @@ class PersisterHelper
$joinData = $assoc; $joinData = $assoc;
} }
$types = array(); $types = array();
$targetClass = $em->getClassMetadata($assoc['targetEntity']); $targetClass = $em->getClassMetadata($assoc['targetEntity']);
foreach ($joinData['joinColumns'] as $joinColumn) { foreach ($joinData['joinColumns'] as $joinColumn) {
$types[] = self::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $em); $types[] = self::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $em);
} }
return $types; return $types;
} }