/**
  * Simple Method for detecting what model to save to
  * by file mime_type
  */
 protected function _detectModelByFileType($mime_type)
 {
     if (empty($mime_type)) {
         return false;
     }
     return FileStorageUtils::detectModelByFileType($mime_type);
 }
コード例 #2
0
 /**
  * Generates an image url based on the image record data and the used Gaufrette adapter to store it
  *
  * @param array $image FileStorage array record or whatever else table that matches this helpers needs without the model, we just want the record fields
  * @param string $version Image version string
  * @param array $options HtmlHelper::image(), 2nd arg options array
  * @return string
  */
 public function display($file, $options = array())
 {
     $className = FileStorageUtils::detectModelByFileType($file['mime_type']);
     if (class_exists($className)) {
         // eg. $this->ImageStorage->display();
         return $this->{$className}->display($file, $options);
     }
     return $this->ImageStorage->fallback($options);
 }
コード例 #3
0
 public function isImage($data)
 {
     if ($model = FileStorageUtils::detectModelByFileType($data['mime_type'])) {
         if ($model == "ImageStorage") {
             return true;
         }
     }
     return false;
 }