lib/Doctrine/ORM/PersistentObject.php
private function completeOwningSide(AssociationMetadata $property, $targetObject)
    {
        // add this object on the owning side as well, for obvious infinite recursion
        // reasons this is only done when called on the inverse side.
        if ($property->isOwningSide()) {
            return;
        }

        $mappedByField    = $property->getMappedBy();
        $targetMetadata   = self::$entityManager->getClassMetadata($property->getTargetEntity());
        $targetProperty   = $targetMetadata->getProperty($mappedByField);
        $setterMethodName = ($targetProperty instanceof ToManyAssociationMetadata ? 'add' : 'set') . $mappedByField;

        $targetObject->{$setterMethodName}($this);
    }
private function completeOwningSide(AssociationMetadata $property, $targetObject)
    {
        // add this object on the owning side as well, for obvious infinite recursion
        // reasons this is only done when called on the inverse side.
        if ($property->isOwningSide()) {
            return;
        }

        $mappedByField    = $property->getMappedBy();
        $targetMetadata   = self::$entityManager->getClassMetadata($property->getTargetEntity());
        $targetProperty   = $targetMetadata->getProperty($mappedByField);
        $setterMethodName = ($targetProperty instanceof ToManyAssociationMetadata ? 'add' : 'set') . $mappedByField;

        $targetObject->{$setterMethodName}($this);
    }
private function completeOwningSide ( AssociationMetadata $ property , $ targetObject ) { // add this object on the owning side as well, for obvious infinite recursion // reasons this is only done when called on the inverse side. if ( $ property -> isOwningSide ( ) ) { return ; } $ mappedByField = $ property -> getMappedBy ( ) ; $ targetMetadata = self :: $ entityManager -> getClassMetadata ( $ property -> getTargetEntity ( ) ) ; $ targetProperty = $ targetMetadata -> getProperty ( $ mappedByField ) ; $ setterMethodName = ( $ targetProperty instanceof ToManyAssociationMetadata ? 'add' : 'set' ) . $ mappedByField ; $ targetObject -> { $ setterMethodName } ( $ this ) ; }
If this is an inverse side association, completes the owning side.

@param object $targetObject
If this is an inverse side association completes the owning side .