55 */
66namespace Magento \Framework \App ;
77
8- use Magento \Framework \App \FeedFactory ;
98use Magento \Framework \App \FeedFactoryInterface ;
9+ use Magento \Framework \ObjectManagerInterface ;
1010use Psr \Log \LoggerInterface ;
1111
1212/**
1515class FeedFactory implements FeedFactoryInterface
1616{
1717 /**
18- * @var \Zend_Feed
18+ * @var FeedProcessorInterface
1919 */
2020 private $ feedProcessor ;
2121
@@ -25,19 +25,27 @@ class FeedFactory implements FeedFactoryInterface
2525 private $ logger ;
2626
2727 /**
28- * @param \Zend_Feed $feedProcessor
28+ * @var ObjectManagerInterface
29+ */
30+ protected $ objectManager ;
31+
32+ /**
33+ * @param ObjectManagerInterface $objectManger
2934 * @param LoggerInterface $logger
35+ * @param array $formats
3036 */
3137 public function __construct (
32- \Zend_Feed $ feedProcessor ,
33- LoggerInterface $ logger
38+ ObjectManagerInterface $ objectManger ,
39+ LoggerInterface $ logger ,
40+ array $ formats
3441 ) {
35- $ this ->feedProcessor = $ feedProcessor ;
42+ $ this ->objectManager = $ objectManger ;
3643 $ this ->logger = $ logger ;
44+ $ this ->formats = $ formats ;
3745 }
3846
3947 /**
40- * Get a new \Magento\Framework\App\Feed object from a custom array
48+ * Get a new \Magento\Framework\App\FeedInterface object from a custom array
4149 *
4250 * @throws \Magento\Framework\Exception\InputException
4351 * @param array $data
@@ -48,9 +56,18 @@ public function create(
4856 array $ data ,
4957 $ format = FeedFactoryInterface::DEFAULT_FORMAT
5058 ) {
59+ if (!isset ($ this ->formats [$ format ])) {
60+ throw new \Magento \Framework \Exception \InputException (
61+ __ ('The format is not supported ' ),
62+ $ e
63+ );
64+ }
5165 try {
52- return $ this ->feedProcessor ->importArray ($ data , $ format );
53- } catch (\Zend_Feed_Exception $ e ) {
66+ return $ this ->objectManager ->create (
67+ $ this ->formats [$ format ],
68+ $ data
69+ );
70+ } catch (\Exception $ e ) {
5471 $ this ->logger ->error ($ e ->getMessage ());
5572 throw new \Magento \Framework \Exception \InputException (
5673 __ ('There has been an error with import ' ),
0 commit comments