Skip to content

Commit

Permalink
Merge pull request #146 from alexdebril/issue/145
Browse files Browse the repository at this point in the history
force_refresh can be set from app/config.yml
  • Loading branch information
alexdebril authored Jun 28, 2017
2 parents 316dffa + 01d93ac commit 63e9a98
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 30 deletions.
12 changes: 1 addition & 11 deletions Controller/StreamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ class StreamController extends Controller
*/
const DEFAULT_SOURCE = 'debril.provider.default';

/**
* parameter used to force refresh at every hit (skips 'If-Modified-Since' usage).
* set it to true for debug purpose.
*/
const FORCE_PARAM_NAME = 'force_refresh';

/**
* @var \DateTime
*/
Expand Down Expand Up @@ -162,11 +156,7 @@ protected function getContent(array $options, $source)
*/
protected function mustForceRefresh()
{
if ($this->container->hasParameter(self::FORCE_PARAM_NAME)) {
return $this->container->getParameter(self::FORCE_PARAM_NAME);
}

return false;
return $this->container->getParameter('debril_rss_atom.force_refresh');
}

/**
Expand Down
4 changes: 4 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public function getConfigTreeBuilder()
->info('Change cache headers so the RSS feed is not cached by public caches (like reverse-proxies...).')
->defaultValue(false)
->end()
->booleanNode('force_refresh')
->info('Do not send 304 status if the feed has not been modified since last hit')
->defaultValue(false)
->end()
->arrayNode('date_formats')
->prototype('scalar')->end()
->end()
Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/DebrilRssAtomExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function load(array $configs, ContainerBuilder $container)

$this->setDateFormats($container, $config);
$container->setParameter('debril_rss_atom.private_feeds', $config['private']);
$container->setParameter('debril_rss_atom.force_refresh', $config['force_refresh']);
}

/**
Expand Down
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,29 +242,15 @@ You can follow either `services.xml` or `CompilerPass` but with services, you ha
### Skipping 304 HTTP Code


The HTTP cache handling can be annoying during development process, you can skip it through configuration in your app/config/parameters.yml file :
The HTTP cache handling can be annoying during development process, you can skip it through configuration in your app/config/config.yml file :

```yml
parameters:
force_refresh: true
debril_rss_atom:
force_refresh: true
```
This way, the `StreamController` will always display your feed's content and return a 200 HTTP code.

### Choosing your own provider

Need to keep the existing routes and add one mapped to a different FeedProvider ? add it own in your routing file :

```xml
<route id="your_route_name" pattern="/your/route/{contentId}">
<default key="_controller">DebrilRssAtomBundle:Stream:index</default>
<default key="format">rss</default>
<default key="source">your.provider.service</default>
</route>
```

The `source` parameter must contain a valid service name defined in your application.

### Private feeds

You may have private feeds, user-specific or behind some authentication.
Expand All @@ -287,7 +273,21 @@ debril_rss_atom:
- 'Y/M/d'
```

### Fetching the repository
### Choosing your own provider

Need to keep the existing routes and add one mapped to a different FeedProvider ? add it own in your routing file :

```xml
<route id="your_route_name" pattern="/your/route/{contentId}">
<default key="_controller">DebrilRssAtomBundle:Stream:index</default>
<default key="format">rss</default>
<default key="source">your.provider.service</default>
</route>
```

The `source` parameter must contain a valid service name defined in your application.

## Fetching the repository

Do this if you want to contribute (and you're welcome to do so):

Expand Down
2 changes: 1 addition & 1 deletion Tests/Controller/StreamControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testIndex()
new \DateTimeZone(date_default_timezone_get())
);

$lastModified->add(new \DateInterval('PT1S'));
$lastModified->add(new \DateInterval('PT10S'));
$this->assertInstanceOf('\DateTime', $lastModified);
$this->assertGreaterThan(0, $response->getMaxAge());
$this->assertGreaterThan(0, strlen($response->getContent()));
Expand Down

0 comments on commit 63e9a98

Please sign in to comment.