コード例 #1
0
ファイル: Manager.php プロジェクト: pscheit/psc-cms-image
 /**
  * Lädt ein Bild aus der Datenbank
  * 
  * @params $input
  * 
  * @param int    $input die ID des Entities
  * @param string $input der gespeicherte sourcePath des Entities (muss / oder \ enthalten)
  * @param string $input der sha1 hash der Bildinformationen des OriginalBildes
  * @return Psc\Image\Image
  * @throws Psc\Image\NotFoundException
  */
 public function load($input)
 {
     try {
         if (is_numeric($input)) {
             $image = $this->imageRep->hydrate((int) $input);
         } elseif (is_string($input) && (mb_strpos($input, '/') !== FALSE || mb_strpos($input, '\\') !== FALSE)) {
             $image = $this->imageRep->hydrateBy(array('sourcePath' => (string) $input));
         } elseif (is_string($input)) {
             // hash
             $image = $this->imageRep->hydrateBy(array('hash' => (string) $input));
         } elseif ($input instanceof Image) {
             $image = $input;
         } elseif ($input instanceof ImagineImage) {
             throw new \Psc\Exception('von einer ImagineResource kann kein Bild geladen werden');
         } else {
             throw new \Psc\Exception('Input kann nicht analyisiert werden: ' . Code::varInfo($input));
         }
         $this->attach($image);
         return $image;
     } catch (\Psc\Doctrine\EntityNotFoundException $e) {
         $e = new NotFoundException('Image nicht gefunden: ' . Code::varInfo($input), 1, $e);
         $e->searchCriteria = $input;
         throw $e;
     }
 }