Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdebril committed Aug 9, 2019
1 parent c6d2b2b commit b19d837
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ The request will be handled by `StreamController`, according to the following st

You must give to RssAtomBundle the content you want it to display in the feed. For that, two steps :

- write a class that implements `FeedContentProviderInterface`. This class that we call a 'provider' will be in charge of building the feed.
- write a class that implements `FeedProviderInterface`. This class that we call a 'provider' will be in charge of building the feed.
- configure the dependency injection to make RssAtomBundle use it

##### FeedContentProviderInterface implementation

Your class just needs to implement the `Debril\RssAtomBundle\Provider\FeedContentProviderInterface` interface, for instance :
Your class just needs to implement the `Debril\RssAtomBundle\Provider\FeedProviderInterface` interface, for instance :

```php
<?php
Expand All @@ -206,14 +206,14 @@ use FeedIo\FeedInterface;
use FeedIo\Feed\Item;
use Debril\RssAtomBundle\Provider\FeedContentProviderInterface;

class Provider implements FeedContentProviderInterface
class Provider implements FeedProviderInterface
{
/**
* @param array $options
* @return \FeedIo\FeedInterface
* @throws \Debril\RssAtomBundle\Exception\FeedNotFoundException
*/
public function getFeedContent(array $options) : FeedInterface
public function getFeed(Request $request) : FeedInterface
{
// build the feed the way you want
$feed = new Feed();
Expand Down Expand Up @@ -241,7 +241,7 @@ class Provider implements FeedContentProviderInterface
}
```

StreamController expects the getFeedContent()'s return value to be a `FeedIo\FeedInterface` instance. It can be a `FeedIo\Feed` or a class of your own and if so, your class MUST implement `\FeedIo\FeedInterface`.
StreamController expects the getFeed()'s return value to be a `FeedIo\FeedInterface` instance. It can be a `FeedIo\Feed` or a class of your own and if so, your class MUST implement `\FeedIo\FeedInterface`.

You can also start from this class to save some time : [App\Feed\Provider.php](/Resources/sample/Provider.php)

Expand Down
7 changes: 4 additions & 3 deletions Resources/sample/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
use App\Repository\PostRepository;

// All you really need to create a feed
use Debril\RssAtomBundle\Provider\FeedContentProviderInterface;
use Debril\RssAtomBundle\Provider\FeedProviderInterface;
use Doctrine\Bundle\DoctrineBundle\Registry;
use FeedIo\Feed;
use FeedIo\Feed\Node\Category;
use FeedIo\FeedInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Router;

class Provider implements FeedContentProviderInterface
class Provider implements FeedProviderInterface
{

protected $logger;
Expand All @@ -43,7 +44,7 @@ public function __construct(LoggerInterface $logger, Registry $registry, Router
* @param array $options
* @return FeedInterface
*/
public function getFeedContent(array $options) : FeedInterface
public function getFeed(Request $request) : FeedInterface
{
$feed = new Feed();
$feed->setTitle('Feed Title')
Expand Down

0 comments on commit b19d837

Please sign in to comment.