-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Zend feed refactoring #9347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
magento-engcom-team
merged 28 commits into
magento:2.3-develop
from
ldusan84:feature/zend_feed_refactoring
May 12, 2018
Merged
Zend feed refactoring #9347
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
ca9e582
Zend_Feed refactoring progress
ldusan84 ed33b18
Tests refactoring
ldusan84 c7ba65a
Fixed unit test
ldusan84 9d0a290
Tidying up files
ldusan84 109047f
Small CS fix
ldusan84 4534a2e
Small CS fix
ldusan84 c413389
More CS fixes
ldusan84 caa4471
Small exception fix
ldusan84 66154e6
Changes after the code review
ldusan84 49bcf98
Zend Feed refactorging WIP
ldusan84 c0b4c7a
Implementing code review requested changes
ldusan84 411d0fc
Merge branch 'develop' into feature/zend_feed_refactoring
9779ebe
Zend Feed refactoring WIP
ldusan84 eba92d0
magento/magento2#9347: Merge branch 'develop' of github.com:magento/m…
ishakhsuvarov 983d74f
magento/magento2#9347: Zend feed refactoring
ishakhsuvarov 0b51e8c
magento/magento2#9347: Zend feed refactoring
ishakhsuvarov 74d431a
magento/magento2#9347: Zend feed refactoring
ishakhsuvarov 7f73d67
Zend Feed refactoring WIP
ldusan84 2933223
Zend Feed refactoring WIP
ldusan84 64610d3
Removed the wrong lines commited
ldusan84 d2d397a
Fixing stuff as requested
ldusan84 0770227
Some code style fixes
ldusan84 735c840
RSS model fix
ldusan84 7e17d20
Unit test fix
ldusan84 46c51ba
RSS model fix
ldusan84 3a3683f
Code style fixes
ldusan84 6311d5c
Code fixes
ldusan84 4462eaf
Added some missing properties and renamed stuff
ldusan84 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Framework\App; | ||
|
||
/** | ||
* Default XML feed class | ||
*/ | ||
class Feed implements FeedInterface | ||
{ | ||
/** | ||
* @var \Zend_Feed | ||
*/ | ||
private $feedProcessor; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $data; | ||
|
||
/** | ||
* @param Zend_Feed $feedProcessor | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Zend_Feed $feedProcessor, | ||
array $data | ||
) { | ||
$this->feedProcessor = $feedProcessor; | ||
$this->data = $data; | ||
} | ||
|
||
/** | ||
* Returns the formatted feed content | ||
* | ||
* @param string $format | ||
* | ||
* @return string | ||
*/ | ||
public function getFormattedContentAs( | ||
$format = self::FORMAT_XML | ||
) { | ||
$feed = $this->feedProcessor::importArray( | ||
$this->data, | ||
FeedFactoryInterface::FORMAT_RSS | ||
); | ||
return $feed->saveXml(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Framework\App; | ||
|
||
use Magento\Framework\App\FeedFactoryInterface; | ||
use Magento\Framework\ObjectManagerInterface; | ||
use Psr\Log\LoggerInterface; | ||
|
||
/** | ||
* Feed factory | ||
*/ | ||
class FeedFactory implements FeedFactoryInterface | ||
{ | ||
/** | ||
* @var ObjectManagerInterface | ||
*/ | ||
private $objectManager; | ||
|
||
/** | ||
* @var LoggerInterface | ||
*/ | ||
private $logger; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $formats; | ||
|
||
/** | ||
* @param ObjectManagerInterface $objectManger | ||
* @param LoggerInterface $logger | ||
* @param array $formats | ||
*/ | ||
public function __construct( | ||
ObjectManagerInterface $objectManger, | ||
LoggerInterface $logger, | ||
array $formats | ||
) { | ||
$this->objectManager = $objectManger; | ||
$this->logger = $logger; | ||
$this->formats = $formats; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function create( | ||
array $data, | ||
$format = FeedFactoryInterface::FORMAT_RSS | ||
) { | ||
if (!isset($this->formats[$format])) { | ||
throw new \Magento\Framework\Exception\InputException( | ||
new \Magento\Framework\Phrase('The format is not supported'), | ||
$e | ||
); | ||
} | ||
|
||
if (!is_subclass_of($this->formats[$format], \Magento\Framework\App\FeedInterface::class)) { | ||
throw new \Magento\Framework\Exception\InputException( | ||
new \Magento\Framework\Phrase('Wrong format handler type'), | ||
$e | ||
); | ||
} | ||
|
||
try { | ||
return $this->objectManager->create( | ||
$this->formats[$format], | ||
$data | ||
); | ||
} catch (\Exception $e) { | ||
$this->logger->error($e->getMessage()); | ||
throw new \Magento\Framework\Exception\RuntimeException( | ||
new \Magento\Framework\Phrase('There has been an error with import'), | ||
$e | ||
); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
lib/internal/Magento/Framework/App/FeedFactoryInterface.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Framework\App; | ||
|
||
/** | ||
* Feed factory interface | ||
*/ | ||
interface FeedFactoryInterface | ||
{ | ||
/** | ||
* RSS feed input format | ||
*/ | ||
const FORMAT_RSS = 'rss'; | ||
|
||
/** | ||
* Returns FeedInterface object from a custom array | ||
* | ||
* @throws \Magento\Framework\Exception\InputException | ||
* @throws \Magento\Framework\Exception\RuntimeException | ||
* @param array $data | ||
* @param string $format | ||
* @return FeedInterface | ||
*/ | ||
public function create( | ||
array $data, | ||
$format = self::FORMAT_RSS | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interface description should be added