Esempio n. 1
0
 /**
  * @param ClassMetadata $classMetadata
  * @return $this
  *
  * @throws MappingException
  */
 private function fromDocument(ClassMetadata $classMetadata)
 {
     if ($classMetadata->isSharded()) {
         throw MappingException::cannotUseShardedCollectionInOutStage($classMetadata->name);
     }
     return parent::out($classMetadata->getCollection());
 }
 /**
  * @depends testLoadMapping
  * @param ClassMetadata $class
  */
 public function testDocumentCollectionNameAndInheritance($class)
 {
     $this->assertEquals('cms_users', $class->getCollection());
     $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $class->inheritanceType);
     return $class;
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
Esempio n. 5
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;
 }