コード例 #1
0
ファイル: MimeTypeRule.php プロジェクト: dyweb/ring
 public function check(AbstractSource $source)
 {
     if (empty($this->allowedTypes)) {
         throw new InvalidArgumentException('Allowed mime types can\'t be empty!');
     }
     $mime = strtolower($source->getMimeType());
     if (array_search($mime, $this->allowedTypes) === false) {
         throw new InvalidArgumentException('Mime type ' . $mime . ' is not allowed');
     }
     return true;
 }
コード例 #2
0
ファイル: SizeRule.php プロジェクト: dyweb/ring
 /**
  * @param AbstractSource $source
  * @return bool
  */
 public function check(AbstractSource $source)
 {
     // TODO: Implement check() method.
     if ($this->maxSize === 0) {
         throw new InvalidArgumentException('maxSize cant\'t be 0');
     }
     if ($this->maxSize < $source->getFileSize()) {
         throw new OutOfBoundsException('File size ' . $source->getFileSize() . ' exceeded maxSize ' . $this->maxSize);
     }
     return true;
 }
コード例 #3
0
ファイル: FileMeta.php プロジェクト: dyweb/ring
 public function __construct(AbstractSource $source)
 {
     // copy all the attributes
     $this->fileName = $source->getFileName();
     $this->fileExtension = $source->getFileExtension();
     $this->displayName = $source->getDisplayName();
     $this->filePath = $source->getFilePath();
     $this->fileSize = $source->getFileSize();
     $this->mimeType = $source->getMimeType();
 }
コード例 #4
0
ファイル: LocalDataStorage.php プロジェクト: dyweb/ring
 /**
  * @TODO: allow hash file name, rolling folder by date etc
  *
  * @param AbstractSource $source
  * @return string
  */
 private function getDstPath(AbstractSource $source)
 {
     return $this->basePath . '/' . $source->getFileName();
 }