Example #1
0
 /**
  * Save file to database and to our filesystem.
  */
 public static function make(Picture $picture, Image $image, $identifier)
 {
     $file = new self();
     $file->picture_id = $picture->id;
     $file->identifier = $identifier;
     $file->mime = $image->mime();
     $file->extension = $image->extension;
     $file->width = $image->width();
     $file->height = $image->height();
     self::checkDirPermission();
     $image->save($file->getFilePath());
     $file->save();
 }
Example #2
0
 /**
  * create a new protected file object which has properties that can be used for writing an actual file to.
  *
  * @param string $name
  *
  * @return ProtectedFile
  */
 public static function createForWriting($name)
 {
     $file = new self();
     $file->name = $name;
     $file->generateUID();
     $path = $file->getFilePath();
     if (!file_exists($path)) {
         if (!@mkdir($path, 0755, true)) {
             throw new Exception("{$path} could not be created: permission denied");
         }
     }
     return $file;
 }
 public static function languageFileExists($pluginCode, $language)
 {
     $model = new self();
     $model->setPluginCode($pluginCode);
     $model->language = $language;
     $filePath = $model->getFilePath();
     return File::isFile($filePath);
 }