Example #1
0
 /**
  * Create all the mapped document databases in the metadata factory.
  */
 public function createDatabases()
 {
     foreach ($this->metadataFactory->getAllMetadata() as $class) {
         if ($class->isMappedSuperclass || $class->isEmbeddedDocument) {
             continue;
         }
         $this->createDocumentDatabase($class->name);
     }
 }
Example #2
0
 /**
  * Ensure collections are sharded for all documents that can be loaded with the
  * metadata factory.
  *
  * @param array $indexOptions Options for `ensureIndex` command. It's performed on an existing collections
  *
  * @throws MongoDBException
  */
 public function ensureSharding(array $indexOptions = array())
 {
     foreach ($this->metadataFactory->getAllMetadata() as $class) {
         if ($class->isMappedSuperclass || !$class->isSharded()) {
             continue;
         }
         $this->ensureDocumentSharding($class->name, $indexOptions);
     }
 }
 public function setUp()
 {
     $this->dm = $this->getMockDocumentManager();
     $cmf = new ClassMetadataFactory();
     $cmf->setConfiguration($this->dm->getConfiguration());
     $cmf->setDocumentManager($this->dm);
     $map = array();
     foreach ($cmf->getAllMetadata() as $cm) {
         $this->documentCollections[$cm->name] = $this->getMockCollection();
         $this->documentDatabases[$cm->name] = $this->getMockDatabase();
         $this->classMetadatas[$cm->name] = $cm;
     }
     $this->dm->unitOfWork = $this->getMockUnitOfWork();
     $this->dm->metadataFactory = $cmf;
     $this->dm->documentCollections = $this->documentCollections;
     $this->dm->documentDatabases = $this->documentDatabases;
     $this->schemaManager = new SchemaManager($this->dm, $cmf);
     $this->dm->schemaManager = $this->schemaManager;
 }
 /**
  * Delete indexes for all documents that can be loaded with the
  * metadata factory.
  */
 public function deleteIndexes()
 {
     foreach ($this->metadataFactory->getAllMetadata() as $class) {
         $this->deleteDocumentIndexes($class->name);
     }
 }