Doctrine\ODM\MongoDB\Mapping\MappingException::cannotUseShardedCollectionInOutStage PHP Method

cannotUseShardedCollectionInOutStage() public static method

public static cannotUseShardedCollectionInOutStage ( string $className ) : MappingException
$className string
return MappingException
    public static function cannotUseShardedCollectionInOutStage($className)
    {
        return new self("Cannot use class '{$className}' as collection for out stage. Sharded collections are not allowed.");
    }

Usage Example

Beispiel #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());
 }