8
8
9
9
namespace Magento \PageBuilder \Block \Adminhtml \Stage ;
10
10
11
+ use Magento \Framework \App \ObjectManager ;
12
+ use Magento \Framework \View \Asset \Minification ;
11
13
use Magento \Framework \View \Element \Template ;
12
14
use Magento \RequireJs \Model \FileManager ;
13
15
use Magento \PageBuilder \Model \Stage \Config ;
@@ -33,24 +35,32 @@ class Render extends Template
33
35
*/
34
36
private $ json ;
35
37
38
+ /**
39
+ * @var Minification
40
+ */
41
+ private $ minification ;
42
+
36
43
/**
37
44
* @param Template\Context $context
38
45
* @param FileManager $fileManager
39
46
* @param Config $config
40
47
* @param Json $json
41
48
* @param array $data
49
+ * @param Minification $minification
42
50
*/
43
51
public function __construct (
44
52
Template \Context $ context ,
45
53
FileManager $ fileManager ,
46
54
Config $ config ,
47
55
Json $ json ,
48
- array $ data = []
56
+ array $ data = [],
57
+ Minification $ minification = null
49
58
) {
50
59
parent ::__construct ($ context , $ data );
51
60
$ this ->fileManager = $ fileManager ;
52
61
$ this ->pageBuilderConfig = $ config ;
53
62
$ this ->json = $ json ;
63
+ $ this ->minification = $ minification ?: ObjectManager::getInstance ()->get (Minification::class);
54
64
}
55
65
56
66
/**
@@ -65,6 +75,20 @@ public function getRequireJsUrl() : string
65
75
return $ asset ->getUrl ();
66
76
}
67
77
78
+ /**
79
+ * Generate the URL to the RequireJS min resolver, if minification enabled.
80
+ *
81
+ * @return string|null
82
+ */
83
+ public function getRequireJsMinUrl () : ?string
84
+ {
85
+ if ($ this ->minification ->isEnabled ('js ' )) {
86
+ $ minResolverAsset = $ this ->fileManager ->createMinResolverAsset ();
87
+ return $ minResolverAsset ->getUrl ();
88
+ }
89
+ return null ;
90
+ }
91
+
68
92
/**
69
93
* Retrieve the URL to the RequireJS Config file
70
94
*
0 commit comments