Skip to content

Commit 74d431a

Browse files
committed
#9347: Zend feed refactoring
- Minor fixes per CR
1 parent 0b51e8c commit 74d431a

File tree

4 files changed

+14
-19
lines changed

4 files changed

+14
-19
lines changed

app/code/Magento/Rss/Model/Rss.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\App\Rss\DataProviderInterface;
1010
use Magento\Framework\Serialize\SerializerInterface;
1111
use Magento\Framework\App\FeedFactoryInterface;
12+
use Magento\Framework\App\FeedInterface;
1213

1314
/**
1415
* Provides functionality to work with RSS feeds
@@ -101,13 +102,7 @@ public function setDataProvider(DataProviderInterface $dataProvider)
101102
*/
102103
public function createRssXml()
103104
{
104-
$feed = $this->feedFactory->create(
105-
$this->getFeeds(),
106-
\Magento\Framework\App\FeedFactoryInterface::DEFAULT_FORMAT
107-
);
108-
109-
return $feed->getFormatedContentAs(
110-
\Magento\Framework\App\FeedInterface::DEFAULT_FORMAT
111-
);
105+
$feed = $this->feedFactory->create($this->getFeeds(), FeedFactoryInterface::DEFAULT_FORMAT);
106+
return $feed->getFormattedContentAs(FeedInterface::DEFAULT_FORMAT);
112107
}
113108
}

app/code/Magento/Rss/Test/Unit/Model/RssTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function testCreateRssXml()
152152
$dataProvider->expects($this->any())->method('getRssData')->will($this->returnValue($this->feedData));
153153

154154
$this->feedMock->expects($this->once())
155-
->method('getFormatedContentAs')
155+
->method('getFormattedContentAs')
156156
->with(\Magento\Framework\App\FeedInterface::DEFAULT_FORMAT)
157157
->will($this->returnValue($this->feedXml));
158158

lib/internal/Magento/Framework/App/Feed.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*/
66
namespace Magento\Framework\App;
77

8-
use \Magento\Framework\App\FeedInterface;
8+
use Magento\Framework\Phrase;
9+
use Magento\Framework\Exception\InputException;
910

1011
class Feed implements \Magento\Framework\App\FeedInterface
1112
{
@@ -25,17 +26,17 @@ public function __construct(\Zend_Feed_Abstract $feed)
2526
/**
2627
* Get the xml from Zend_Feed_Abstract object
2728
*
29+
* @param string $format
2830
* @return string
31+
* @throws InputException
2932
*/
30-
public function getFormatedContentAs(
31-
$format = FeedInterface::DEFAULT_FORMAT
32-
) {
33+
public function getFormattedContentAs(string $format = FeedInterface::DEFAULT_FORMAT): string
34+
{
3335
if ($format === FeedInterface::DEFAULT_FORMAT) {
3436
return $this->feed->saveXml();
3537
}
36-
throw new \Magento\Framework\Exception\RuntimeException(
37-
__('Given feed format is not supported'),
38-
$e
38+
throw new InputException(
39+
new Phrase('Given feed format is not supported')
3940
);
4041
}
4142
}

lib/internal/Magento/Framework/App/FeedInterface.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ interface FeedInterface
1010
const DEFAULT_FORMAT = 'xml';
1111

1212
/**
13+
* @param string $format
1314
* @return string
1415
*/
15-
public function getFormatedContentAs(
16-
$format = self::DEFAULT_FORMAT
17-
);
16+
public function getFormattedContentAs(string $format = self::DEFAULT_FORMAT): string;
1817
}

0 commit comments

Comments
 (0)