/** * Delete all logs for a given Feed. * * @param Request $request * @param Feed $feed The document Feed (retrieving for a ParamConverter with the slug) * * @return RedirectResponse */ public function deleteAllAction(Request $request, Feed $feed) { $form = $this->createDeleteAllForm(); $form->handleRequest($request); if ($form->isValid()) { $res = $this->getDocumentManager()->getRepository('Api43FeedBundle:FeedLog')->deleteAllByFeedId($feed->getId()); $this->get('session')->getFlashBag()->add('notice', $res['n'] . ' documents deleted!'); } return $this->redirect($this->generateUrl('feed_edit', array('slug' => $feed->getSlug()))); }
/** * Render the feed in specified format. * * @param Feed $feed Feed to render * * @return string * * @throws \InvalidArgumentException if given format formatter does not exists */ public function render(Feed $feed) { $items = $this->dm->getRepository('Api43FeedBundle:FeedItem')->findByFeed($feed->getId(), $feed->getSortBy()); $feedUrl = $this->router->generate('feed_xml', array('slug' => $feed->getSlug()), true); switch ($feed->getFormatter()) { case 'rss': $formatter = new Formatter\RssFormatter($feed, $items, $feedUrl, $this->generator); break; case 'atom': $formatter = new Formatter\AtomFormatter($feed, $items, $feedUrl, $this->generator); break; default: throw new \InvalidArgumentException(sprintf("Format '%s' is not available. Please see documentation.", $feed->getFormatter())); } return $formatter->render(); }