/** * @param ProjectModel $project */ protected function cleanProjectEnvironment($project) { // clean out old db if it is present $projectDb = MongoStore::connect($project->databaseName()); foreach ($projectDb->listCollections() as $collectionInfo) { if ($collectionInfo->getName() != 'system.indexes') { $collection = $projectDb->selectCollection($collectionInfo->getName()); $collection->drop(); } } // clean up assets folder $folderPath = $project->getAssetsFolderPath(); $cleanupFiles = glob($folderPath . '/*'); foreach ($cleanupFiles as $cleanupFile) { @unlink($cleanupFile); } @rmdir($folderPath); }
/** * @param string $databaseName * @param string $collectionName * @param string $idKey defaults to id */ public function __construct($databaseName, $collectionName, $idKey = 'id') { $this->_db = MongoStore::connect($databaseName); $this->_collection = $this->_db->selectCollection($collectionName); $this->_idKey = $idKey; }