/**
* 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;
}