コード例 #1
0
ファイル: MetaFile.php プロジェクト: vectrex/vxphp
 /**
  * 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;
 }
コード例 #2
0
ファイル: MetaFileQuery.php プロジェクト: vectrex/vxphp
 /**
  * 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;
 }