/** * {@inheritdoc} */ public function getOwningTable($fieldName) { return $this->persister->getOwningTable($fieldName); }
/** * Modified version of BasicEntityPersister::prepareUpdateData() * git revision d9fc5388f1aa1751a0e148e76b4569bd207338e9 (v2.5.3) * * @license MIT * * @author Roman Borschel <*****@*****.**> * @author Giorgio Sironi <*****@*****.**> * @author Benjamin Eberlei <*****@*****.**> * @author Alexander <*****@*****.**> * @author Fabio B. Silva <*****@*****.**> * @author Rob Caiger <*****@*****.**> * @author Simon Mönch <*****@*****.**> * * @param EntityPersister|BasicEntityPersister $persister * @param $entity * * @return array */ private function prepareUpdateData($persister, $entity) { $uow = $this->em->getUnitOfWork(); $classMetadata = $persister->getClassMetadata(); $versionField = null; $result = array(); if (($versioned = $classMetadata->isVersioned) != false) { $versionField = $classMetadata->versionField; } foreach ($uow->getEntityChangeSet($entity) as $field => $change) { if (isset($versionField) && $versionField == $field) { continue; } if (isset($classMetadata->embeddedClasses[$field])) { continue; } $newVal = $change[1]; if (!isset($classMetadata->associationMappings[$field])) { $columnName = $classMetadata->columnNames[$field]; $result[$persister->getOwningTable($field)][$columnName] = $newVal; continue; } $assoc = $classMetadata->associationMappings[$field]; // Only owning side of x-1 associations can have a FK column. if (!$assoc['isOwningSide'] || !($assoc['type'] & ClassMetadata::TO_ONE)) { continue; } if ($newVal !== null) { if ($uow->isScheduledForInsert($newVal)) { $newVal = null; } } $newValId = null; if ($newVal !== null) { if (!$uow->isInIdentityMap($newVal)) { continue; } $newValId = $uow->getEntityIdentifier($newVal); } $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); $owningTable = $persister->getOwningTable($field); foreach ($assoc['joinColumns'] as $joinColumn) { $sourceColumn = $joinColumn['name']; $targetColumn = $joinColumn['referencedColumnName']; $result[$owningTable][$sourceColumn] = $newValId ? $newValId[$targetClass->getFieldForColumn($targetColumn)] : null; } } return $result; }