/** * Fetch the files from inside a folder, not including any folders. * @param FolderInterface $folder * * @return FileInterface[] */ public function getFiles(FolderInterface $folder) { $files = array(); $gridFs = ConnectionHandler::getInstance()->getConnection(); # Fetch the folder by it's path. $mongoFolder = MongoFolder::loadFromFolderInterface($folder); $filesQueryConditions = array(); $filesQueryConditions[] = array('type' => 'file'); $filesQueryConditions[] = array('parent' => $mongoFolder->getMongoId()); $searchFilesQuery = array('$and' => $filesQueryConditions); $cursor = $gridFs->find($searchFilesQuery); while (($document = $cursor->getNext()) != null) { /* @var $document MongoGridFsFile */ $files[] = MongoFile::load($document->file["_id"]); } return $files; }
/** * Move this object to within the provided parent folder. * @param FolderInterface $parent - the folder we wish to move this file/folder to within. * * @return $this - this modified item. */ public function setParentFolder(FolderInterface $parent) { $parentMongoFolder = MongoFolder::loadFromFolderInterface($parent); $this->updateField("parent", $parentMongoFolder->getMongoId()); return $this; }