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.
20 * @param string $format
22 * @Route("/export/{id}.{format}", name="export_entry", requirements={
23 * "format": "epub|mobi|pdf|json|xml|txt|csv",
27 * @return \Symfony\Component\HttpFoundation\Response
29 public function downloadEntryAction(Entry
$entry, $format)
32 return $this->get('wallabag_core.helper.entries_export')
34 ->updateTitle('entry')
36 } catch (\InvalidArgumentException
$e) {
37 throw new NotFoundHttpException($e->getMessage());
42 * Export all entries for current user.
44 * @param string $format
45 * @param string $category
47 * @Route("/export/{category}.{format}", name="export_entries", requirements={
48 * "format": "epub|mobi|pdf|json|xml|txt|csv",
49 * "category": "all|unread|starred|archive|tag_entries|untagged"
52 * @return \Symfony\Component\HttpFoundation\Response
54 public function downloadEntriesAction($format, $category)
56 $method = ucfirst($category);
57 $methodBuilder = 'getBuilderFor'.$method.'ByUser';
58 $entries = $this->getDoctrine()
59 ->getRepository('WallabagCoreBundle:Entry')
60 ->$methodBuilder($this->getUser()->getId())
65 return $this->get('wallabag_core.helper.entries_export')
66 ->setEntries($entries)
67 ->updateTitle($method)
69 } catch (\InvalidArgumentException
$e) {
70 throw new NotFoundHttpException($e->getMessage());