File tree Expand file tree Collapse file tree 4 files changed +18
-10
lines changed
lib/internal/Magento/Framework/App Expand file tree Collapse file tree 4 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -27,12 +27,12 @@ public function __construct(
27
27
*
28
28
* @return string
29
29
*/
30
- public function getFormatedContentAs (
31
- $ format = self ::DEFAULT_FORMAT
30
+ public function getFormattedContentAs (
31
+ $ format = self ::FORMAT_XML
32
32
) {
33
33
$ feed = $ this ->feed ::importArray (
34
34
$ this ->data ,
35
- FeedFactoryInterface::DEFAULT_FORMAT
35
+ FeedFactoryInterface::FORMAT_RSS
36
36
);
37
37
return $ this ->feed ->saveXml ();
38
38
}
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ class FeedFactory implements FeedFactoryInterface
27
27
/**
28
28
* @var ObjectManagerInterface
29
29
*/
30
- protected $ objectManager ;
30
+ private $ objectManager ;
31
31
32
32
/**
33
33
* @param ObjectManagerInterface $objectManger
@@ -54,22 +54,30 @@ public function __construct(
54
54
*/
55
55
public function create (
56
56
array $ data ,
57
- $ format = FeedFactoryInterface::DEFAULT_FORMAT
57
+ $ format = FeedFactoryInterface::FORMAT_RSS
58
58
) {
59
59
if (!isset ($ this ->formats [$ format ])) {
60
60
throw new \Magento \Framework \Exception \InputException (
61
61
__ ('The format is not supported ' ),
62
62
$ e
63
63
);
64
64
}
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
+
65
73
try {
66
74
return $ this ->objectManager ->create (
67
75
$ this ->formats [$ format ],
68
76
$ data
69
77
);
70
78
} catch (\Exception $ e ) {
71
79
$ this ->logger ->error ($ e ->getMessage ());
72
- throw new \Magento \Framework \Exception \InputException (
80
+ throw new \Magento \Framework \Exception \RuntimeException (
73
81
__ ('There has been an error with import ' ),
74
82
$ e
75
83
);
Original file line number Diff line number Diff line change 8
8
interface FeedFactoryInterface
9
9
{
10
10
11
- const DEFAULT_FORMAT = 'rss ' ;
11
+ const FORMAT_RSS = 'rss ' ;
12
12
13
13
/**
14
14
* Returns FeedInterface object from a custom array
@@ -20,6 +20,6 @@ interface FeedFactoryInterface
20
20
*/
21
21
public function create (
22
22
array $ data ,
23
- $ format = self ::DEFAULT_FORMAT
23
+ $ format = self ::FORMAT_RSS
24
24
);
25
25
}
Original file line number Diff line number Diff line change 7
7
8
8
interface FeedInterface
9
9
{
10
- const DEFAULT_FORMAT = 'xml ' ;
10
+ const FORMAT_XML = 'xml ' ;
11
11
12
12
/**
13
13
* @return string
14
14
*/
15
15
public function getFormattedContentAs (
16
- $ format = self ::DEFAULT_FORMAT
16
+ $ format = self ::FORMAT_XML
17
17
);
18
18
}
You can’t perform that action at this time.
0 commit comments