/** * Registers the mapping as an inverse mapping, if it is a mapping on the * inverse side of an association mapping. * * @param AssociationMapping The mapping to register as inverse if it is a mapping * for the inverse side of an association. */ private function _registerMappingIfInverse(AssociationMapping $assoc) { if ($assoc->isInverseSide()) { $this->inverseMappings[$assoc->getMappedByFieldName()] = $assoc; } }
/** * INTERNAL: * Sets the collection owner. Used (only?) during hydration. * * @param object $entity * @param AssociationMapping $assoc */ public function setOwner($entity, AssociationMapping $assoc) { $this->_owner = $entity; $this->_association = $assoc; if ($assoc->isInverseSide()) { // For sure bi-directional $this->_backRefFieldName = $assoc->mappedByFieldName; } else { $targetClass = $this->_em->getClassMetadata($assoc->targetEntityName); if (isset($targetClass->inverseMappings[$assoc->sourceFieldName])) { // Bi-directional $this->_backRefFieldName = $targetClass->inverseMappings[$assoc->sourceFieldName]->sourceFieldName; } } }