/**
  * Returns the reference representation to be stored in mongodb or null if not applicable.
  *
  * @param ClassMetadata $class
  * @param Document $doc
  * @return array|null
  */
 private function _prepareDocReference(ClassMetadata $class, $doc)
 {
     if (!is_object($doc)) {
         return $doc;
     }
     $id = $this->_uow->getDocumentIdentifier($doc);
     $ref = array('$ref' => $class->getCollection(), '$id' => $id, '$db' => $class->getDB());
     return $ref;
 }
 /**
  * Returns the reference representation to be stored in mongodb or null if not applicable.
  *
  * @param ClassMetadata $class
  * @param Document $doc
  * @return array|null
  */
 private function _prepareDocReference(ClassMetadata $class, $doc)
 {
     if (!is_object($doc)) {
         return $doc;
     }
     $id = $this->_uow->getDocumentIdentifier($doc);
     if (null !== $id) {
         $id = $class->getPHPIdentifierValue($id);
     }
     $ref = array($this->_cmd . 'ref' => $class->getCollection(), $this->_cmd . 'id' => $id, $this->_cmd . 'db' => $class->getDB());
     return $ref;
 }
Пример #3
0
 /**
  * returns the reference representation to be stored in mongodb
  * or null if not applicable
  * @param ClassMetadata $class
  * @param Document $doc
  * @return array|null
  */
 private function _prepareDocReference($class, $doc)
 {
     $docOid = spl_object_hash($doc);
     if (isset($this->_documentIdentifiers[$docOid])) {
         $id = $this->_documentIdentifiers[$docOid];
         $ref = array('$ref' => $class->getCollection(), '$id' => $id, '$db' => $class->getDB());
         return $ref;
     }
     return null;
 }