Skip to content

Commit d2d397a

Browse files
committed
Fixing stuff as requested
1 parent 64610d3 commit d2d397a

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ public function __construct(
2727
*
2828
* @return string
2929
*/
30-
public function getFormatedContentAs(
31-
$format = self::DEFAULT_FORMAT
30+
public function getFormattedContentAs(
31+
$format = self::FORMAT_XML
3232
) {
3333
$feed = $this->feed::importArray(
3434
$this->data,
35-
FeedFactoryInterface::DEFAULT_FORMAT
35+
FeedFactoryInterface::FORMAT_RSS
3636
);
3737
return $this->feed->saveXml();
3838
}

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class FeedFactory implements FeedFactoryInterface
2727
/**
2828
* @var ObjectManagerInterface
2929
*/
30-
protected $objectManager;
30+
private $objectManager;
3131

3232
/**
3333
* @param ObjectManagerInterface $objectManger
@@ -54,22 +54,30 @@ public function __construct(
5454
*/
5555
public function create(
5656
array $data,
57-
$format = FeedFactoryInterface::DEFAULT_FORMAT
57+
$format = FeedFactoryInterface::FORMAT_RSS
5858
) {
5959
if (!isset($this->formats[$format])) {
6060
throw new \Magento\Framework\Exception\InputException(
6161
__('The format is not supported'),
6262
$e
6363
);
6464
}
65+
66+
if (!is_subclass_of($this->formats[$format], '\Magento\Framework\App\FeedInterface')) {
67+
throw new \Magento\Framework\Exception\InputException(
68+
__('Wrong format handler type'),
69+
$e
70+
);
71+
}
72+
6573
try {
6674
return $this->objectManager->create(
6775
$this->formats[$format],
6876
$data
6977
);
7078
} catch (\Exception $e) {
7179
$this->logger->error($e->getMessage());
72-
throw new \Magento\Framework\Exception\InputException(
80+
throw new \Magento\Framework\Exception\RuntimeException(
7381
__('There has been an error with import'),
7482
$e
7583
);

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

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

11-
const DEFAULT_FORMAT = 'rss';
11+
const FORMAT_RSS = 'rss';
1212

1313
/**
1414
* Returns FeedInterface object from a custom array
@@ -20,6 +20,6 @@ interface FeedFactoryInterface
2020
*/
2121
public function create(
2222
array $data,
23-
$format = self::DEFAULT_FORMAT
23+
$format = self::FORMAT_RSS
2424
);
2525
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
interface FeedInterface
99
{
10-
const DEFAULT_FORMAT = 'xml';
10+
const FORMAT_XML = 'xml';
1111

1212
/**
1313
* @return string
1414
*/
1515
public function getFormattedContentAs(
16-
$format = self::DEFAULT_FORMAT
16+
$format = self::FORMAT_XML
1717
);
1818
}

0 commit comments

Comments
 (0)