Exemple #1
0
 protected function createFileObject()
 {
     $file = new File();
     $model = $this->model;
     $file->group = $this->group;
     $file->folderName = $this->folderName;
     $file->addErrors($model->getFileErrors($this->group));
     return $file;
 }
Exemple #2
0
 public function getFiles($group = null)
 {
     if (null == $group) {
         throw new InvalidParamException("missing one parameter for FileBehavior method `getFile(\$group)`");
     }
     return File::getByModelAndGroup($this->owner, $group);
 }
Exemple #3
0
 public function actionServeImage()
 {
     $preset = $_GET['preset'];
     list($width, $height) = $this->resolvePreset($preset);
     $image = File::getByName($_GET['name']);
     if (isset($image) && is_file($image->path)) {
         $presetFolder = $image->getPresetFolder($preset);
         $fileCachePath = $presetFolder . $image->filename;
         FileHelper::createDirectory($presetFolder);
         if ($preset == 'editor') {
             copy($image->path, $fileCachePath);
         } else {
             Image::getImagine()->open($image->path)->thumbnail(new \Imagine\Image\Box($width, $height))->save($fileCachePath);
         }
         header('Content-type: ' . mime_content_type($fileCachePath));
         readfile($fileCachePath);
         exit;
     }
 }