/** * Uploads the given file to the given album * @param $file * @param Album $album * @throws \Exception */ public function uploadToAlbum(File $file, Album $album) { if (!$this->supported($file)) { throw new \Exception("File not supported by Colibri."); } $filePath = $file->getPath() . DIRECTORY_SEPARATOR . $file->getFilename(); $fileData = getimagesize($filePath); $picture = new Picture(); $picture->setFile($filePath); $picture->setFilename($file->getClientOriginalName()); $picture->setMimeType($file->getMimeType()); $picture->setImageWidth($fileData[0]); $picture->setImageHeight($fileData[1]); $album->addPicture($picture); $this->manager->persist($album); $this->manager->flush(); $this->filter($picture, 'thumbnail'); $this->filter($picture, 'bignail'); }
/** * Add album * * @param Album $album */ public function addAlbum(Album $album) { $this->albums[] = $album; $album->setNode($this); }