コード例 #1
0
 /**
  * Convert a FolderInterface object into a MongoFolder object.
  * @param FolderInterface $folder
  * @return \MongoFolder
  */
 public static function loadFromFolderInterface(FolderInterface $folder)
 {
     $conditions = array();
     $conditions[] = array("path" => $folder->getPath());
     $conditions[] = array("name" => $folder->getName());
     $query = array('$and' => $conditions);
     /* @var $gridFsDoc MongoGridFsFile */
     $gridFs = ConnectionHandler::getInstance()->getConnection();
     $gridFsDoc = $gridFs->findOne($query);
     if ($gridFsDoc === null) {
         print "Failed to find mongo folder for provided folder interface." . PHP_EOL;
         print "path: " . $folder->getPath() . PHP_EOL;
         print "name: " . $folder->getName() . PHP_EOL;
         die;
     }
     /* @var $mongoId MongoId */
     $folderMongoId = $gridFsDoc->file["_id"];
     $name = $gridFsDoc->file['name'];
     $creationTime = $gridFsDoc->path['creation_time'];
     $mongoFolder = new MongoFolder($name, $creationTime);
     if (isset($gridFsDoc->file["parent"])) {
         $parent = MongoFolder::loadFromMongoId($gridFsDoc->file["parent"]);
         $mongoFolder->setParentFolder($parent);
     }
     $mongoFolder->mMongoId = $folderMongoId;
     $mongoFolder->mGridFsFile = $gridFsDoc;
     return $mongoFolder;
 }
コード例 #2
0
 /**
  * @param FolderInterface $folder
  * @param FolderInterface $parent
  * @return array
  */
 public function getValidateFolderResult(FolderInterface $folder, FolderInterface $parent)
 {
     $check = array('Child folder name not specified' => !$folder->getName(), 'Child folder path not specified' => !$folder->getPath(), 'Child folder created time not specified' => !$folder->getCreatedTime(), 'Parent folder name not specified' => !$parent->getName(), 'Parent folder path not specified' => !$parent->getPath(), 'Parent folder created time not specified' => !$parent->getCreatedTime());
     if ($folder->getPath()) {
         $key = 'Folder with a path ' . $folder->getPath() . ' has been already created';
         $check[$key] = $this->folderExists($folder->getPath());
     }
     return $check;
 }
コード例 #3
0
 /**
  * Fetch the folders within the provided folder.
  * @param FolderInterface $folder
  *
  * @return FolderInterface[]
  */
 public function getFolders(FolderInterface $folder)
 {
     $folder->getPath();
 }
コード例 #4
0
 /**
  * @param FolderInterface $folder
  *
  * @return FileInterface[]
  */
 public function getFiles(FolderInterface $folder)
 {
     // get dir
     $dir = $folder->getPath();
     // create empty array for the files
     $files = array();
     // scan the dir for the files
     $contents = scandir($dir);
     if (isset($contents)) {
         // loop results
         foreach ($contents as $item) {
             // check if result is a file or a folder, we only want the files
             $curr_path = $dir . "/" . $item;
             if (file_exists($curr_path) && !is_dir($curr_path)) {
                 $files[] = $item;
             }
         }
     }
     // return file list
     return $files;
 }
コード例 #5
0
ファイル: FileClass.php プロジェクト: pjanaway/php-fms-test
 /**
  * @param FolderInterface $parent
  *
  * @return $this
  */
 public function setParentFolder(FolderInterface $parent)
 {
     $this->path = $parent->getPath();
 }