コード例 #1
0
ファイル: FilesystemFile.php プロジェクト: vectrex/vxphp
 /**
  * constructs mapper for filesystem files
  * if folder is provided a bulk generation is assumed and certain checks are omitted
  *
  * @param string $path
  * @param FilesystemFolder $folder
  *
  * @throws FilesystemFileException
  */
 public function __construct($path, FilesystemFolder $folder = NULL)
 {
     if ($folder) {
         $path = $folder->getPath() . $path;
     } else {
         $path = realpath($path);
     }
     if (!file_exists($path)) {
         throw new FilesystemFileException("File {$path} does not exist!", FilesystemFileException::FILE_DOES_NOT_EXIST);
     }
     $this->folder = $folder ? $folder : FilesystemFolder::getInstance(pathinfo($path, PATHINFO_DIRNAME));
     $this->filename = pathinfo($path, PATHINFO_BASENAME);
     $this->fileInfo = new \SplFileInfo($path);
 }
コード例 #2
0
ファイル: MetaFolder.php プロジェクト: vectrex/vxphp
 /**
  * creates a metafolder instance
  * requires either id or path stored in db
  *
  * @param string $path of metafolder
  * @param integer $id of metafolder
  */
 private function __construct($path = NULL, $id = NULL, $dbEntry = NULL)
 {
     if (isset($path)) {
         $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
         $this->fullPath = Application::getInstance()->extendToAbsoluteAssetsPath($path);
         $this->data = $this->getDbEntryByPath($path);
     } else {
         if (isset($id)) {
             $this->data = $this->getDbEntryById($id);
             $this->fullPath = substr($this->data['Path'], 0, 1) == DIRECTORY_SEPARATOR ? $this->data['Path'] : Application::getInstance()->getAbsoluteAssetsPath() . $this->data['Path'];
         } else {
             if (isset($dbEntry)) {
                 $this->data = $dbEntry;
                 $this->fullPath = substr($this->data['Path'], 0, 1) == DIRECTORY_SEPARATOR ? $this->data['Path'] : Application::getInstance()->getAbsoluteAssetsPath() . $this->data['Path'];
             }
         }
     }
     $this->filesystemFolder = FilesystemFolder::getInstance($this->fullPath);
     $this->id = $this->data['foldersID'];
     $this->level = (int) $this->data['level'];
     $this->l = (int) $this->data['l'];
     $this->r = (int) $this->data['r'];
     $this->obscure_files = (bool) $this->data['Obscure_Files'];
     $this->name = basename($this->fullPath);
 }