FeedWriter\Item::setDescription PHP Method

setDescription() public method

Set the 'description' element of feed item
public setDescription ( string $description ) : self
$description string The content of the 'description' or 'summary' element
return self
    public function setDescription($description)
    {
        $tag = $this->version == Feed::ATOM ? 'summary' : 'description';
        return $this->addElement($tag, $description);
    }

Usage Example

コード例 #1
0
ファイル: PostsController.php プロジェクト: aisuhua/blog-1
 /**
  * Handles the RSS action. Constructs the rss feed of the latest posts. The
  * number of posts to return is stored in the configuration section
  *
  * @return Response
  */
 public function rssAction()
 {
     $feed = new RSS2();
     $feed->setEncoding('UTF-8');
     $feed->setTitle($this->config->rss->title);
     $feed->setDescription($this->config->rss->description);
     $feed->setLink($this->getFullUrl());
     $posts = $this->finder->getLatest(1);
     foreach ($posts as $post) {
         $feedItem = new Item();
         $feedItem->setTitle($post->getTitle());
         $feedItem->setLink($this->getFullUrl('/post/' . $post->getSlug()));
         $feedItem->setDescription($post->getContent());
         $feedItem->setDate($post->getDate());
         $feed->addItem($feedItem);
     }
     $response = new Response();
     $response->setHeader('Content-Type', 'application/xml');
     $response->setContent($feed->generateFeed());
     return $response;
 }