Skip to content

Commit 9779ebe

Browse files
committed
Zend Feed refactoring WIP
1 parent 411d0fc commit 9779ebe

File tree

6 files changed

+19
-32
lines changed

6 files changed

+19
-32
lines changed

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

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

8+
use \Magento\Framework\App\FeedInterface;
9+
810
class Feed implements \Magento\Framework\App\FeedInterface
911
{
1012
/**
@@ -26,9 +28,9 @@ public function __construct(\Zend_Feed_Abstract $feed)
2628
* @return string
2729
*/
2830
public function getFormatedContentAs(
29-
$format = FeedOutputFormatsInterface::DEFAULT_FORMAT
31+
$format = FeedInterface::DEFAULT_FORMAT
3032
) {
31-
if ($format === FeedOutputFormatsInterface::DEFAULT_FORMAT) {
33+
if ($format === FeedInterface::DEFAULT_FORMAT) {
3234
return $this->feed->saveXml();
3335
}
3436
throw new \Magento\Framework\Exception\RuntimeException(

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
namespace Magento\Framework\App;
77

88
use Magento\Framework\App\FeedFactory;
9+
use Magento\Framework\App\FeedFactoryInterface;
910
use Psr\Log\LoggerInterface;
1011

1112
/**
1213
* Feed factory
1314
*/
14-
class FeedFactory implements \Magento\Framework\App\FeedFactoryInterface
15+
class FeedFactory implements FeedFactoryInterface
1516
{
1617
/**
1718
* @var \Zend_Feed
@@ -38,18 +39,20 @@ public function __construct(
3839
/**
3940
* Get a new \Magento\Framework\App\Feed object from a custom array
4041
*
41-
* @throws \Magento\Framework\Exception\RuntimeException
42+
* @throws \Magento\Framework\Exception\InputException
4243
* @param array $data
4344
* @param string $format
4445
* @return \Magento\Framework\App\FeedInterface
4546
*/
46-
public function importArray(array $data, $format = FeedFormatsInterface::DEFAULT_FORMAT)
47-
{
47+
public function create(
48+
array $data,
49+
$format = FeedFactoryInterface::DEFAULT_FORMAT
50+
) {
4851
try {
4952
return $this->feedProcessor->importArray($data, $format);
5053
} catch (\Zend_Feed_Exception $e) {
5154
$this->logger->error($e->getMessage());
52-
throw new \Magento\Framework\Exception\RuntimeException(
55+
throw new \Magento\Framework\Exception\InputException(
5356
__('There has been an error with import'),
5457
$e
5558
);

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
interface FeedFactoryInterface
99
{
1010

11+
const DEFAULT_FORMAT = 'rss';
12+
1113
/**
1214
* Returns FeedInterface object from a custom array
1315
*
@@ -16,8 +18,8 @@ interface FeedFactoryInterface
1618
* @param string $format
1719
* @return FeedInterface
1820
*/
19-
public function importArray(
21+
public function create(
2022
array $data,
21-
$format = FeedFormatsInterface::DEFAULT_FORMAT
23+
$format = self::DEFAULT_FORMAT
2224
);
2325
}

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

Lines changed: 0 additions & 11 deletions
This file was deleted.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77

88
interface FeedInterface
99
{
10+
const DEFAULT_FORMAT = 'xml';
11+
1012
/**
1113
* @return string
1214
*/
1315
public function getFormatedContentAs(
14-
$format = FeedOutputFormatsInterface::DEFAULT_FORMAT
16+
$format = self::DEFAULT_FORMAT
1517
);
1618
}

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

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)