3 namespace Wallabag\CoreBundle\Controller
;
5 use Pagerfanta\Adapter\DoctrineORMAdapter
;
6 use Pagerfanta\Pagerfanta
;
7 use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter
;
8 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route
;
9 use Symfony\Bundle\FrameworkBundle\Controller\Controller
;
10 use Wallabag\CoreBundle\Entity\Entry
;
11 use Wallabag\UserBundle\Entity\User
;
13 class RssController
extends Controller
16 * Shows unread entries for current user.
18 * @Route("/{username}/{token}/unread.xml", name="unread_rss", defaults={"_format"="xml"})
19 * @ParamConverter("user", class="WallabagUserBundle:User", converter="username_rsstoken_converter")
21 * @return \Symfony\Component\HttpFoundation\Response
23 public function showUnreadAction(User
$user)
25 return $this->showEntries('unread', $user);
29 * Shows read entries for current user.
31 * @Route("/{username}/{token}/archive.xml", name="archive_rss")
32 * @ParamConverter("user", class="WallabagUserBundle:User", converter="username_rsstoken_converter")
34 * @return \Symfony\Component\HttpFoundation\Response
36 public function showArchiveAction(User
$user)
38 return $this->showEntries('archive', $user);
42 * Shows starred entries for current user.
44 * @Route("/{username}/{token}/starred.xml", name="starred_rss")
45 * @ParamConverter("user", class="WallabagUserBundle:User", converter="username_rsstoken_converter")
47 * @return \Symfony\Component\HttpFoundation\Response
49 public function showStarredAction(User
$user)
51 return $this->showEntries('starred', $user);
55 * Global method to retrieve entries depending on the given type
56 * It returns the response to be send.
58 * @param string $type Entries type: unread, starred or archive
61 * @return \Symfony\Component\HttpFoundation\Response
63 private function showEntries($type, User
$user)
65 $repository = $this->getDoctrine()->getRepository('WallabagCoreBundle:Entry');
69 $qb = $repository->getBuilderForStarredByUser($user->getId());
73 $qb = $repository->getBuilderForArchiveByUser($user->getId());
77 $qb = $repository->getBuilderForUnreadByUser($user->getId());
81 throw new \
InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
84 $pagerAdapter = new DoctrineORMAdapter($qb->getQuery());
85 $entries = new Pagerfanta($pagerAdapter);
87 $perPage = $user->getConfig()->getRssLimit() ?: $this->getParameter('wallabag_core.rss_limit');
88 $entries->setMaxPerPage($perPage);
90 return $this->render('@WallabagCore/themes/common/Entry/entries.xml.twig', [
92 'entries' => $entries,