コード例 #1
0
 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);
 }
コード例 #2
0
 /**
  *
  * @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;
 }
コード例 #3
0
 /**
  * @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;
 }