/**
  * Create the specified file.
  * I dont understand why this exists with the provided $file. Surely if we want to 
  * create a file we should be calling the file's constructor or one of its static
  * creation methods?
  * @param FileInterface   $file - the file to be created?
  * @param FolderInterface $parent - the parent folder to stick the file within.
  *
  * @return FileInterface
  */
 public function createFile(FileInterface $file, FolderInterface $parent)
 {
     $filepath = $file->getPath() . '/' . $file->getName();
     $gridFs = ConnectionHandler::getInstance()->getConnection();
     $timeNow = time();
     $mongoFolder = MongoFolder::loadFromFolderInterface($parent);
     $metadata = array('creation_time' => $file->getCreatedTime(), 'modification_time' => $file->getModifiedTime(), 'parent' => $mongoFolder->getMongoId(), 'type' => 'file');
     # This is another hack where the getPath() method here is returning the path to the
     # file as it is locally stored in the linux filesystem, rather than the path of where
     # it will be stored withing the mongo based filesystem.
     $mongoId = $gridFs->storeFile($file->getPath(), $metadata);
     $mongoFile = MongoFile::loadFromMongoId($mongoId);
     return $mongoFile;
 }
Esempio n. 2
0
 /**
  * @param FileInterface $file
  *
  * @return bool
  */
 public function deleteFile(FileInterface $file)
 {
     if (@unlink($file->getPath())) {
         return true;
     }
     return false;
 }
Esempio n. 3
0
 public function imageInterface($file)
 {
     if (get_class($file) != 'FileInterface') {
         $file = new FileInterface($file);
     }
     $this->file = $file;
     if (!($this->image = image::init($file->getPath()))) {
         return false;
     }
 }
Esempio n. 4
0
 /**
  * @param FileInterface $file
  * @return array
  */
 private function getValidateFileResult(FileInterface $file)
 {
     $check = array('File name not specified' => !$file->getName(), 'Filesize not specified' => is_null($file->getSize()), 'Created time not specified' => !$file->getCreatedTime(), 'File path already exists' => $this->fileExists($file->getPath()));
     return $check;
 }
Esempio n. 5
0
 /**
  * @param FileInterface $file
  * @return bool
  */
 private function isPhpFile(FileInterface $file) : bool
 {
     return pathinfo($file->getPath(), PATHINFO_EXTENSION) === 'php';
 }