Skip to content

Commit

Permalink
Merge pull request #178 from alexdebril/issue/176
Browse files Browse the repository at this point in the history
Issue/176
  • Loading branch information
alexdebril authored Oct 5, 2018
2 parents f6d246f + f029135 commit 87b9327
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 14 deletions.
41 changes: 37 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,42 @@ feed-io provides two interfaces, each one being dedicated to feed's consuming an
- [FeedInterface](https://github.com/alexdebril/feed-io/blob/master/src/FeedIo/FeedInterface.php) to handle the feed
- [ItemInterface](https://github.com/alexdebril/feed-io/blob/master/src/FeedIo/Feed/ItemInterface.php) to handle feed's items

### Getting a FeedIo instance

You can fetch a `FeedIo\FeedIo` instance through dependency injection or the service container.

#### Dependency injection (highly recommended)

```php

namespace App\Feed;

class Consumer
{

/**
* @type \FeedIo\FeedIo
*/
private $feedIo;

public function __construct(FeedIo $feedIo)
{
$this->feedIo = $feedIo;
}
}

```

#### Service Container

Wherever you have access to the service container :

```php
<?php
// get feedio
$feedIo = $this->container->get('feedio');
```

### Feed Reading

To read a feed you need to use the `feedio` service which provides two methods for that : `read()` and `readSince()`. This service is based upon [FeedIo](https://github.com/alexdebril/feed-io/blob/master/src/FeedIo/FeedIo.php).
Expand All @@ -92,12 +128,9 @@ To read a feed you need to use the `feedio` service which provides two methods f
- `$feed` (optional) : a FeedInterface instance. The default is a new `\FeedIo\Feed` instance
- `$modifiedSince` (optional) : the last time you read this feed. This is useful to fetch only the articles which were published after your last hit.

Wherever you have access to the service container :
With a `\FeedIo\FeedIo` instance called `$feedIo` :
```php
<?php
// get feedio
$feedIo = $this->container->get('feedio');

// this date is used to fetch only the latest items
$modifiedSince = new \DateTime($date);

Expand Down
17 changes: 7 additions & 10 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,18 @@ services:
arguments:
- '%debril_rss_atom.date_formats%'

FeedIo\FeedIo:
alias: feedio

debril.rss_atom.provider:
class: '%debril.rss_atom.provider.class%'

debril.provider.default:
alias: debril.rss_atom.provider

Debril\RssAtomBundle\Provider\FeedContentProviderInterface:
alias: debril.rss_atom.provider

Debril\RssAtomBundle\Controller\StreamController:
public: false
tags:
# add multiple tags to control multiple args
- name: controller.service_arguments
action: indexAction
argument: provider
id: debril.rss_atom.provider
- name: controller.service_arguments
action: indexAction
argument: feedIo
id: feedio
tags: ['controller.service_arguments']

0 comments on commit 87b9327

Please sign in to comment.