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; }
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); }
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; } }