Пример #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());
 }
Пример #2
0
 /**
  * @param object $document
  *
  * @return array
  * @throws MongoDBException
  */
 private function getShardKeyQuery($document)
 {
     if (!$this->class->isSharded()) {
         return array();
     }
     $shardKey = $this->class->getShardKey();
     $keys = array_keys($shardKey['keys']);
     $data = $this->uow->getDocumentActualData($document);
     $shardKeyQueryPart = array();
     foreach ($keys as $key) {
         $mapping = $this->class->getFieldMappingByDbFieldName($key);
         $this->guardMissingShardKey($document, $key, $data);
         $value = Type::getType($mapping['type'])->convertToDatabaseValue($data[$mapping['fieldName']]);
         $shardKeyQueryPart[$key] = $value;
     }
     return $shardKeyQueryPart;
 }
Пример #3
0
 /**
  * Adds inherited shard key to the subclass mapping.
  *
  * @param ClassMetadata $subClass
  * @param ClassMetadata $parentClass
  */
 private function setInheritedShardKey(ClassMetadata $subClass, ClassMetadata $parentClass)
 {
     if ($parentClass->isSharded()) {
         $subClass->setShardKey($parentClass->shardKey['keys'], $parentClass->shardKey['options']);
     }
 }