示例#1
0
 public function filesByType($types = null)
 {
     if ($types == null) {
         $files = UploadedFiles::where(array('project_id' => $this->id))->get();
     } else {
         $files = array();
         foreach ($types as $type) {
             $filesTemp = UploadedFiles::where(array('project_id' => $this->id, "{$type}" => 1))->get();
             foreach ($filesTemp as $file) {
                 $files[] = $file;
             }
         }
     }
     return $files;
 }
示例#2
0
文件: Dir.php 项目: point/cassea
 /**
  * Сохраняет файлы из UploadedFiles в директорию.
  *
  * Возвращает массив загруженных файлов.
  *
  * @throws FileSystemException если перемещение файлов прошло неуспешно.
  * @return array (File)
  */
 public function upload(UploadedFiles $uf)
 {
     $res = array();
     foreach ($uf->getUploaded() as $f) {
         if (move_uploaded_file($f['tmp_name'], $f = $this->getFile($f['name']))) {
             $res[] = $f;
         } else {
             throw new FileSystemException('Fail in move_uploaded_file: ' . $f['name']);
         }
     }
     return $res;
 }