Example #1
0
 /**
  * creates metafolder from current filesystemfolder
  */
 public function createMetaFolder()
 {
     try {
         return MetaFolder::getInstance($this->getPath());
     } catch (MetaFolderException $e) {
         return MetaFolder::create($this);
     }
 }
Example #2
0
 /**
  * move file to a new folder
  *
  * @param MetaFolder $destination
  * @throws MetaFileException
  */
 public function move(MetaFolder $destination)
 {
     // nothing to do
     if ($destination === $this->metaFolder) {
         return;
     }
     // move filesystem file first
     try {
         $this->filesystemFile->move($destination->getFilesystemFolder());
     } catch (FilesystemFileException $e) {
         throw new MetaFileException("Moving '{$this->getFilename()}' to '{$destination->getFullPath()}' failed.");
     }
     // update reference in db
     try {
         Application::getInstance()->getDb()->execute('UPDATE files SET foldersID = ? WHERE filesID = ?', array($destination->getId(), $this->id));
     } catch (\Exception $e) {
         throw new MetaFileException("Moving '{$this->getFilename()}' to '{$destination->getFullPath()}' failed.");
     }
     // update instance lookup
     unset(self::$instancesByPath[$this->getPath()]);
     $this->metaFolder = $destination;
     self::$instancesByPath[$this->getPath()] = $this;
 }
Example #3
0
 /**
  * add appropriate WHERE clause that filters for $metaFolder
  *
  * @param MetaFolder $category
  * @return MetaFileQuery
  */
 public function filterByFolder(MetaFolder $folder)
 {
     $this->addCondition("f.foldersID = ?", $folder->getId());
     return $this;
 }