Skip to content

Commit

Permalink
Merge pull request #150 from alexdebril/hotfix/routing
Browse files Browse the repository at this point in the history
Installation instructions for sf 3.3
  • Loading branch information
alexdebril authored Jul 27, 2017
2 parents af0aaa0 + b193165 commit aeef697
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
9 changes: 5 additions & 4 deletions Controller/StreamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ protected function createStreamResponse(array $options, $format, $source = self:

if ($this->mustForceRefresh() || $content->getLastModified() > $this->getModifiedSince()) {
$response = new Response($this->getFeedIo()->format($content, $format));
$response->headers->set('Content-Type', 'application/xhtml+xml');
$this->setFeedHeaders($response, $content);
$this->setFeedHeaders($response, $content, $format);

} else {
$response = new Response();
Expand All @@ -107,11 +106,13 @@ protected function createStreamResponse(array $options, $format, $source = self:
/**
* @param Response $response
* @param FeedInterface $feed
* @param string $format
* @return $this
*/
protected function setFeedHeaders(Response $response, FeedInterface $feed)
protected function setFeedHeaders(Response $response, FeedInterface $feed, $format)
{
$response->headers->set('Content-Type', 'application/xhtml+xml');
$contentType = 'json' == $format ? 'application/json':'application/xhtml+xml';
$response->headers->set('Content-Type', $contentType);
if (! $this->isPrivate() ) {
$response->setPublic();
}
Expand Down
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,24 @@ You can try rss-atom-bundle through its [Demo](https://rss-atom-demo.herokuapp.c

As a Symfony Bundle, RssAtomBundle must be installed using Composer. If you do not know Composer, please refer to its website: http://getcomposer.org/

### Installation in a Symfony project
### Your application uses Symfony 3.3 or later

This is the most common way if you want to add RssAtomBundle into an existing project.
Activate Symfony's [contrib recipes](https://github.com/symfony/recipes-contrib) and use Composer to require the bundle :

composer require debril/rss-atom-bundle
```shell
composer config extra.symfony.allow-contrib true
composer require debril/rss-atom-bundle
```

That's it. To check the installation, you can start your application and hit http://localhost:8000/rss in your browser. You should see a mock RSS stream.

### If your application uses Symfony < 3.3

Install the bundle using Composer :

```shell
composer require debril/rss-atom-bundle
```

Add the bundle's routing configuration in app/config/routing.yml :

Expand All @@ -43,7 +56,6 @@ rssatom:
resource: "@DebrilRssAtomBundle/Resources/config/routing.yml"

```
#### If your application uses Symfony < 3.3

Edit your app/AppKernel.php to register the bundle in the registerBundles() method as above:

Expand All @@ -61,8 +73,6 @@ class AppKernel extends Kernel
new Debril\RssAtomBundle\DebrilRssAtomBundle(),
```

This step will not be necessary anymore starting from Symfony 3.3.

## Usage

rss-atom-bundle is designed to read feeds across the internet and to publish your own using [feed-io](https://github.com/alexdebril/feed-io)
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ feed_atom:
defaults: { _controller: DebrilRssAtomBundle:Stream:index, "format": 'atom', "id": null }

feed_json:
path: /atom/{id}
path: /json/{id}
defaults: { _controller: DebrilRssAtomBundle:Stream:index, "format": 'json', "id": null }

feed_mock:
Expand Down
4 changes: 4 additions & 0 deletions Tests/Controller/StreamControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function testGetAtom()

$response = $client->getResponse();
$this->assertEquals('200', $response->getStatusCode());
$this->assertEquals('application/xhtml+xml', $response->headers->get('content-type'));

$atom = new Document($response->getContent());

Expand All @@ -65,6 +66,7 @@ public function testGetRss()

$response = $client->getResponse();
$this->assertEquals('200', $response->getStatusCode());
$this->assertEquals('application/xhtml+xml', $response->headers->get('content-type'));

$rss = new Document($response->getContent());

Expand All @@ -79,7 +81,9 @@ public function testGetJson()
$client->request('GET', '/json/1');

$response = $client->getResponse();

$this->assertEquals('200', $response->getStatusCode());
$this->assertEquals('application/json', $response->headers->get('content-type'));

$json = new Document($response->getContent());

Expand Down

0 comments on commit aeef697

Please sign in to comment.