private function PersistentObject::completeOwningSide in Plug 7
If this is an inverse side association, completes the owning side.
Parameters
string $field:
ClassMetadata $targetClass:
object $targetObject:
Return value
void
2 calls to PersistentObject::completeOwningSide()
- PersistentObject::add in lib/
doctrine/ common/ lib/ Doctrine/ Common/ Persistence/ PersistentObject.php - Adds an object to a collection.
- PersistentObject::set in lib/
doctrine/ common/ lib/ Doctrine/ Common/ Persistence/ PersistentObject.php - Sets a persistent fields value.
File
- lib/
doctrine/ common/ lib/ Doctrine/ Common/ Persistence/ PersistentObject.php, line 167
Class
- PersistentObject
- PersistentObject base class that implements getter/setter methods for all mapped fields and associations by overriding __call.
Namespace
Doctrine\Common\PersistenceCode
private function completeOwningSide($field, $targetClass, $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 ($this->cm
->isAssociationInverseSide($field)) {
$mappedByField = $this->cm
->getAssociationMappedByTargetField($field);
$targetMetadata = self::$objectManager
->getClassMetadata($targetClass);
$setter = ($targetMetadata
->isCollectionValuedAssociation($mappedByField) ? "add" : "set") . $mappedByField;
$targetObject
->{$setter}($this);
}
}