/** * @param FileEntity $file * @param $deleteUrl * @return array */ public function getFileJson(FileEntity $file, $deleteUrl) { /** @var \Media\Service\File $fileService */ $fileService = $this->sm->get('Media\\Service\\File'); $thumbnailUrl = null; $type = null; switch ($file->getType()) { case FileEntity::IMAGE_FILETYPE: $thumbnailUrl = $fileService->getFullUrl($file->getThumb()); $type = 'image/jpeg'; break; case FileEntity::AUDIO_FILETYPE: $thumbnailUrl = $fileService->getFullUrl($file->getUrlPart()); $type = 'audio/mp3'; break; default: break; } return ['url' => $fileService->getFullUrl($file->getUrlPart()), 'thumbnailUrl' => $thumbnailUrl, 'name' => '', 'type' => $type, 'size' => '', 'deleteUrl' => $deleteUrl, 'deleteType' => 'DELETE']; }
/** * Adds new image id to session * * @param \Media\Entity\File $image */ public function addImageToSession(\Media\Entity\File $image) { $session = self::getSession(); array_push($session->ids, $image->getId()); }
/** * Converts file according to its type * * @param FileEntity $file * @return FileEntity */ public function convertFile(FileEntity $file) { if ($file->getType() == FileEntity::VIDEO_FILETYPE && $file->getExtension() !== Video::MP4_EXT) { $file = $this->sm->get('Media\\Service\\Video')->convertVideoToMp4($file); } elseif ($file->getType() == FileEntity::AUDIO_FILETYPE && $file->getExtension() !== Audio::MP3_EXT) { $file = $this->sm->get('Media\\Service\\Audio')->convertAudioToMp3($file); } return $file; }