3 namespace Wallabag\CoreBundle\Controller
;
5 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route
;
6 use Symfony\Bundle\FrameworkBundle\Controller\Controller
;
7 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException
;
8 use Wallabag\CoreBundle\Entity\Entry
;
11 * The try/catch can be removed once all formats will be implemented.
12 * Still need implementation: txt.
14 class ExportController
extends Controller
17 * Gets one entry content.
21 * @Route("/export/{id}.{format}", name="export_entry", requirements={
22 * "format": "epub|mobi|pdf|json|xml|txt|csv",
26 public function downloadEntryAction(Entry
$entry, $format)
29 return $this->get('wallabag_core.helper.entries_export')
31 ->updateTitle('entry')
33 } catch (\InvalidArgumentException
$e) {
34 throw new NotFoundHttpException($e->getMessage());
39 * Export all entries for current user.
41 * @Route("/export/{category}.{format}", name="export_entries", requirements={
42 * "format": "epub|mobi|pdf|json|xml|txt|csv",
43 * "category": "all|unread|starred|archive"
46 public function downloadEntriesAction($format, $category)
48 $method = ucfirst($category);
49 $methodBuilder = 'getBuilderFor'.$method.'ByUser';
50 $entries = $this->getDoctrine()
51 ->getRepository('WallabagCoreBundle:Entry')
52 ->$methodBuilder($this->getUser()->getId())
57 return $this->get('wallabag_core.helper.entries_export')
58 ->setEntries($entries)
59 ->updateTitle($method)
61 } catch (\InvalidArgumentException
$e) {
62 throw new NotFoundHttpException($e->getMessage());