Skip to content

Commit

Permalink
Merge pull request #187 from alexdebril/issue/5.0
Browse files Browse the repository at this point in the history
BC Break : FeedContentProvider replaced with FeedProvider
  • Loading branch information
alexdebril authored Aug 9, 2019
2 parents 5c0ef9b + fbc45f4 commit f34efe4
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 726 deletions.
32 changes: 6 additions & 26 deletions Controller/StreamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@
namespace Debril\RssAtomBundle\Controller;

use Debril\RssAtomBundle\Provider\FeedProviderInterface;
use Debril\RssAtomBundle\Request\ModifiedSince;
use Debril\RssAtomBundle\Provider\FeedContentProviderInterface;
use Debril\RssAtomBundle\Exception\FeedException\FeedNotFoundException;
use Debril\RssAtomBundle\Response\FeedBuilder;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
* Class StreamController.
*/
class StreamController
{

Expand All @@ -23,40 +17,26 @@ class StreamController
*/
private $feedBuilder;

/**
* @var ModifiedSince
*/
private $modifiedSince;

/**
* @param FeedBuilder $feedBuilder
* @param ModifiedSince $modifiedSince
*/
public function __construct(FeedBuilder $feedBuilder, ModifiedSince $modifiedSince)
public function __construct(FeedBuilder $feedBuilder)
{
$this->feedBuilder = $feedBuilder;
$this->modifiedSince = $modifiedSince;
}

/**
* @param Request $request
* @param FeedProviderInterface $provider
* @param LoggerInterface $logger
* @return Response
*/
public function indexAction(Request $request, FeedProviderInterface $provider, LoggerInterface $logger) : Response
public function indexAction(Request $request, FeedProviderInterface $provider) : Response
{
try {
if ($provider instanceof FeedContentProviderInterface) {
$logger->info('The \\Debril\\RssAtomBundle\\Provider\\FeedContentProviderInterface is deprecated since rss-atom-bundle 4.3, use FeedProviderInterface instead');
$options = $request->attributes->get('_route_params');
$options['Since'] = $this->modifiedSince->getValue();
$feed = $provider->getFeedContent($options);
} else {
$feed = $provider->getFeed($request);
}

return $this->feedBuilder->getResponse($request->get('format', 'rss'), $feed);
return $this->feedBuilder->getResponse(
$request->get('format', 'rss'),
$provider->getFeed($request)
);
} catch (FeedNotFoundException $e) {
throw new NotFoundHttpException('feed not found');
}
Expand Down
126 changes: 0 additions & 126 deletions Provider/DoctrineFeedContentProvider.php

This file was deleted.

31 changes: 0 additions & 31 deletions Provider/FeedContentProviderInterface.php

This file was deleted.

17 changes: 1 addition & 16 deletions Provider/MockProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
use FeedIo\FeedInterface;
use Symfony\Component\HttpFoundation\Request;

/**
* Class MockProvider.
*/
class MockProvider implements FeedContentProviderInterface
class MockProvider implements FeedProviderInterface
{

/**
Expand All @@ -35,18 +32,6 @@ public function getFeed(Request $request): FeedInterface
return $this->buildFeed($id);
}

/**
* @param array $options
* @return FeedInterface
* @throws FeedNotFoundException
*/
public function getFeedContent(array $options) : FeedInterface
{
$id = array_key_exists('id', $options) ? $options['id'] : '';

return $this->buildFeed($id);
}

/**
* @param string $id
* @return FeedInterface
Expand Down
17 changes: 11 additions & 6 deletions Tests/Provider/MockProviderTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php

namespace Debril\RssAtomBundle\Provider;

use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;

/**
* Generated by PHPUnit_SkeletonGenerator 1.2.0 on 2013-01-25 at 23:47:50.
*/
Expand Down Expand Up @@ -30,23 +33,25 @@ protected function tearDown()
}

/**
* @covers Debril\RssAtomBundle\Provider\MockProvider::getFeedContent
* @covers Debril\RssAtomBundle\Provider\MockProvider::getFeed
*/
public function testGetContent()
{
$options = array('id' => 'some id');
$feed = $this->object->getFeedContent($options);
$request = new Request(['id' => 'some-id']);
$feed = $this->object->getFeed($request);

$this->assertInstanceOf('FeedIo\FeedInterface', $feed);
}

/**
* @covers Debril\RssAtomBundle\Provider\MockProvider::getFeedContent
* @covers Debril\RssAtomBundle\Provider\MockProvider::getFeed
* @expectedException \Debril\RssAtomBundle\Exception\FeedException\FeedNotFoundException
*/
public function testGet404()
{
$options = array('id' => 'not-found');
$this->object->getFeedContent($options);
$request = new Request(['id' => 'not-found']);
$feed = $this->object->getFeed($request);

$this->object->getFeed($request);
}
}
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@
"require-dev": {
"phpunit/phpunit": "~7.0",
"doctrine/common": "~2.3",
"doctrine/doctrine-bundle": "~1.2",
"symfony/validator": ">3.0",
"symfony/finder": ">3.0",
"symfony/browser-kit": ">3.0",
"symfony/yaml": "^4.0"
},
"suggest": {
"doctrine/doctrine-bundle": "allow to provide feeds' content from database"
"symfony/yaml": "^4.0",
"symfony/framework-bundle": "^4.3"
},
"autoload": {
"psr-0": {
Expand All @@ -38,6 +35,9 @@
},
"target-dir": "Debril/RssAtomBundle",
"config": {
"platform": {
"php": "7.1.27"
},
"bin-dir": "bin",
"preferred-install": {
"*": "dist"
Expand Down
Loading

0 comments on commit f34efe4

Please sign in to comment.