If this is an inverse side association complete the owning side.
string $field:
ClassMetadata $targetClass:
object $targetObject:
private function completeOwningSide($field, $targetClass, $targetObject) {
// add this object on the owning side aswell, for obvious infinite recursion
// reasons this is only done when called on the inverse side.
if ($this->cm
->isAssociationInverseSide($field)) {
$mappedByField = $this->cm
->getAssociationMappedByTargetField($field);
$targetMetadata = self::$objectManager
->getClassMetadata($targetClass);
$setter = ($targetMetadata
->isCollectionValuedAssociation($mappedByField) ? "add" : "set") . $mappedByField;
$targetObject
->{$setter}($this);
}
}