API: getEntry can return EPUB

This commit is contained in:
Pascal MARTIN 2016-10-04 13:57:18 +02:00 committed by Jeremy Benoist
parent 3d4b0b3064
commit 24de866534
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C

View file

@ -127,11 +127,18 @@ class WallabagRestController extends FOSRestController
*
* @return JsonResponse
*/
public function getEntryAction(Entry $entry)
public function getEntryAction(Entry $entry, $_format)
{
$this->validateAuthentication();
$this->validateUserAccess($entry->getUser()->getId());
if ($_format === 'epub') {
return $this->get('wallabag_core.helper.entries_export')
->setEntries($entry)
->updateTitle('entry')
->exportAs($_format);
}
$json = $this->get('serializer')->serialize($entry, 'json');
return (new JsonResponse())->setJson($json);