Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'macnibblet/hotfix/feed-strategy'
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanDotPro committed Jul 4, 2012
2 parents 851904c + fd2a195 commit a2eb795
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/Model/FeedModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ class FeedModel extends ViewModel
*/
protected $type = false;

/**
* A feed is always terminal
*
* @var bool
*/
protected $terminate = true;

/**
* @return \Zend\Feed\Writer\Feed
*/
public function getFeed()
{
if ($this->feed instanceof Feed) {
Expand All @@ -67,8 +77,8 @@ public function getFeed()

/**
* Set the feed object
*
* @param Feed $feed
*
* @param Feed $feed
* @return FeedModel
*/
public function setFeed(Feed $feed)
Expand All @@ -79,7 +89,7 @@ public function setFeed(Feed $feed)

/**
* Get the feed type
*
*
* @return false|string
*/
public function getFeedType()
Expand Down
12 changes: 11 additions & 1 deletion src/Strategy/FeedStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,20 @@ public function injectResponse(ViewEvent $e)
? 'application/rss+xml'
: 'application/atom+xml';

$model = $e->getModel();
$charset = '';

if ($model instanceof Model\FeedModel) {

$feed = $model->getFeed();

$charset = '; charset=' . $feed->getEncoding() . ';';
}

// Populate response
$response = $e->getResponse();
$response->setContent($result);
$headers = $response->getHeaders();
$headers->addHeaderLine('content-type', $feedType);
$headers->addHeaderLine('content-type', $feedType . $charset);
}
}

0 comments on commit a2eb795

Please sign in to comment.