コード例 #1
0
 /**
  * Load file with ID matching that submitted, and assign it to the bundle.
  *
  * @param Bundle $bundle
  * @param array $data
  * @throws Exception\BundleBuildException    Throws exception if no file exists with submitted file ID
  * @throws Exception\BundleBuildException    Throws exception if the file loaded is not an image
  */
 private function _addImage(Bundle $bundle, array $data)
 {
     if (!empty($data[Form\BundleForm::IMAGE])) {
         $id = $data[Form\BundleForm::IMAGE];
         $image = $this->_fileLoader->getByID($id);
         if (!$image) {
             throw new Exception\BundleBuildException('Could not load file with ID `' . $id . '`');
         }
         if (!$image instanceof File\File || $image->typeID !== File\Type::IMAGE) {
             throw new Exception\BundleBuildException('File with ID `' . $id . '` is not a valid image');
         }
         $bundle->setImage($image);
     }
 }
コード例 #2
0
 /**
  * Lazy load image assigned to bundle using the FileLoader
  *
  * @param BundleProxy $bundle
  *
  * @return array|\Message\Mothership\FileManager\File\File
  */
 public function getImage(BundleProxy $bundle)
 {
     return $this->_fileLoader->getByID($bundle->getImageID());
 }