8
8
namespace Magento \CatalogGraphQl \Plugin ;
9
9
10
10
use Magento \Catalog \Model \Product ;
11
- use Magento \Framework \Message \ MessageInterface ;
12
- use Magento \Framework \View \ DesignLoader as ViewDesignLoader ;
11
+ use Magento \Framework \App \ AreaList ;
12
+ use Magento \Framework \App \ State ;
13
13
use Magento \Framework \Message \ManagerInterface ;
14
14
use Magento \Catalog \Block \Product \ImageFactory ;
15
+ use Magento \Framework \Message \MessageInterface ;
15
16
16
17
/**
17
18
* Load necessary design files for GraphQL
18
19
*/
19
20
class DesignLoader
20
21
{
21
22
/**
22
- * @var DesignLoader
23
+ * @var ManagerInterface
23
24
*/
24
- private $ designLoader ;
25
+ private ManagerInterface $ messageManager ;
25
26
26
27
/**
27
- * @var ManagerInterface
28
+ * Application
29
+ *
30
+ * @var AreaList
31
+ */
32
+ private AreaList $ areaList ;
33
+
34
+ /**
35
+ * Layout
36
+ *
37
+ * @var State
28
38
*/
29
- private $ messageManager ;
39
+ private State $ appState ;
30
40
31
41
/**
32
- * @param ViewDesignLoader $designLoader
33
42
* @param ManagerInterface $messageManager
43
+ * @param AreaList $areaList
44
+ * @param State $appState
34
45
*/
35
46
public function __construct (
36
- ViewDesignLoader $ designLoader ,
37
- ManagerInterface $ messageManager
47
+ ManagerInterface $ messageManager ,
48
+ AreaList $ areaList ,
49
+ State $ appState
38
50
) {
39
- $ this ->designLoader = $ designLoader ;
51
+ $ this ->areaList = $ areaList ;
52
+ $ this ->appState = $ appState ;
40
53
$ this ->messageManager = $ messageManager ;
41
54
}
42
55
@@ -57,10 +70,10 @@ public function beforeCreate(
57
70
array $ attributes = null
58
71
) {
59
72
try {
60
- $ this ->designLoader ->load ();
73
+ $ area = $ this ->areaList ->getArea ($ this ->appState ->getAreaCode ());
74
+ $ area ->load (\Magento \Framework \App \Area::PART_DESIGN );
61
75
} catch (\Magento \Framework \Exception \LocalizedException $ e ) {
62
76
if ($ e ->getPrevious () instanceof \Magento \Framework \Config \Dom \ValidationException) {
63
- /** @var MessageInterface $message */
64
77
$ message = $ this ->messageManager
65
78
->createMessage (MessageInterface::TYPE_ERROR )
66
79
->setText ($ e ->getMessage ());
0 commit comments