/** * @param \Symfony\Component\OptionsResolver\Options $options * @return \Debril\FeedAggregatorBundle\Provider\Feed * @throws FeedNotFoundException */ public function getFeedContent(array $options) { // fetch feed from data repository /* $qb->select( 'e' ) ->from( 'Entity\Event', 'e' ) ->Where( $qb->expr()->andX( $qb->expr()->between('e.dateStart', ':from', ':to') ) ) ->orderBy('e.dateStart', 'ASC') ->setFirstResult( $offset ) ->setMaxResults( $limit );*/ $repository = $this->doctrine->getRepository('OpenSourceFeedBundle:Post'); // createQueryBuilder automatically selects FROM AppBundle:Product // and aliases it to "p" $query = $repository->createQueryBuilder('p')->orderBy('p.date', 'DESC')->setMaxResults(10)->getQuery(); $entities = $query->getResult(); $feed = new FeedContent(); //$feed -> setLastModified(); $feed->setLastModified(new \DateTime()); foreach ($entities as $post) { $item = new Item(); $item->setTitle($post->getTitle()); $item->setUpdated($post->getDate()); $item->setLink($this->generateUrl('post_show', array('id' => $post->getId(), 'slug' => $post->getSlug()))); $feed->addItem($item); } /*$feed = new FeedContent; * * $feed->setLastModified($lastTimeANewsWasUpdated); * * $feed->setTitle('your feed title'); * $feed->setDescription('the description'); * $feed->addItem($item);*/ // if the feed is an actual FeedOut instance, then return it //if ($feed instanceof \Debril\RssAtomBundle\Protocol\FeedOut) return $feed; // $feed is null, which means no Feed was found with this id. throw new FeedNotFoundException(); }
/** * * @param Options $options * * @throws \Debril\RssAtomBundle\Exception\FeedNotFoundException * * @return FeedContent */ public function getFeedContent(Options $options) { $feed = new FeedContent(); $feed->setTitle('Symfony Sverige'); $maxModified = null; foreach ($this->blogContentProvider->getAllEntries() as $entry) { $markdown = $this->markdownParser->transformMarkdown($entry->getContent()); $url = $this->router->generate('blog', ['permalink' => $entry->getPermalink()], Router::ABSOLUTE_URL); $item = new FeedItem(); $item->setUpdated($entry->getModifiedAt()); $item->setTitle($entry->getTitle()); $item->setDescription($this->excerpt->getExcerpt($markdown)); $item->setLink($url); $feed->addItem($item); if (!$maxModified || $entry->getModifiedAt() > $maxModified) { $maxModified = $entry->getModifiedAt(); } } if ($maxModified) { $feed->setLastModified($maxModified); } return $feed; }
/** * @param array $options * * @return FeedContent * * @throws FeedNotFoundException */ public function getFeedContent(array $options) { $content = new FeedContent(); $id = array_key_exists('id', $options) ? $options['id'] : null; if ($id === 'not-found') { throw new FeedNotFoundException(); } $content->setPublicId($id); $content->setTitle('thank you for using RssAtomBundle'); $content->setDescription('this is the mock FeedContent'); $content->setLink('https://raw.github.com/alexdebril/rss-atom-bundle/'); $content->setLastModified(new \DateTime()); $item = new Item(); $item->setPublicId('1'); $item->setLink('https://raw.github.com/alexdebril/rss-atom-bundle/somelink'); $item->setTitle('This is an item'); $item->setSummary('this stream was generated using the MockProvider class'); $item->setDescription('lorem ipsum ....'); $item->setUpdated(new \DateTime()); $item->setComment('http://example.com/comments'); $item->setAuthor('Contributor'); $content->addItem($item); return $content; }
protected function setUp() { $this->feed = new FeedContent(); $this->feed->setPublicId('feed id'); $this->feed->setLink('http://example.com'); $this->feed->setTitle('feed title'); $this->feed->setDescription('feed subtitle'); $this->feed->setLastModified(new \DateTime()); $item = new Item(); $item->setPublicId('item id'); $item->setLink('http://example.com/1'); $item->setSummary('lorem ipsum'); $item->setTitle('title 1'); $item->setUpdated(new \DateTime()); $item->setComment('http://linktothecomments.com'); $item->setAuthor('Contributor'); $media = new Media(); $media->setUrl('http://media'); $media->setUrl('image/jpeg'); $item->addMedia($media); $this->feed->addItem($item); }