7
7
8
8
namespace Magento \Framework \Css \PreProcessor \Instruction ;
9
9
10
+ use Magento \Framework \App \DeploymentConfig ;
10
11
use Magento \Framework \App \ObjectManager ;
11
12
use Magento \Framework \Css \PreProcessor \ErrorHandlerInterface ;
13
+ use Magento \Framework \Module \Manager as ModuleManager ;
12
14
use Magento \Framework \View \Asset \File \FallbackContext ;
13
15
use Magento \Framework \View \Asset \LocalInterface ;
14
16
use Magento \Framework \View \Asset \PreProcessorInterface ;
17
+ use Magento \Framework \View \Asset \Repository as AssetRepository ;
18
+ use Magento \Framework \View \Design \Theme \ListInterface as ThemeListInterface ;
15
19
use Magento \Framework \View \Design \Theme \ThemeProviderInterface ;
20
+ use Magento \Framework \View \Design \ThemeInterface ;
16
21
use Magento \Framework \View \DesignInterface ;
17
22
use Magento \Framework \View \File \CollectorInterface ;
18
23
@@ -28,6 +33,8 @@ class MagentoImport implements PreProcessorInterface
28
33
const REPLACE_PATTERN =
29
34
'#//@magento_import(?P<reference>\s+\(reference\))?\s+[ \'\"](?P<path>(?![/ \\\]|\w:[/ \\\])[^\" \']+)[ \'\"]\s*?;# ' ;
30
35
36
+ private const CONFIG_PATH_SCD_ONLY_ENABLED_MODULES = 'static_content_only_enabled_modules ' ;
37
+
31
38
/**
32
39
* @var DesignInterface
33
40
*/
@@ -44,12 +51,12 @@ class MagentoImport implements PreProcessorInterface
44
51
protected $ errorHandler ;
45
52
46
53
/**
47
- * @var \Magento\Framework\View\Asset\Repository
54
+ * @var AssetRepository
48
55
*/
49
56
protected $ assetRepo ;
50
57
51
58
/**
52
- * @var \Magento\Framework\View\Design\Theme\ListInterface
59
+ * @var ThemeListInterface
53
60
* @deprecated 100.0.2
54
61
*/
55
62
protected $ themeList ;
@@ -60,33 +67,40 @@ class MagentoImport implements PreProcessorInterface
60
67
private $ themeProvider ;
61
68
62
69
/**
63
- * @var \Magento\Framework\Module\Manager
70
+ * @var DeploymentConfig
71
+ */
72
+ private $ deploymentConfig ;
73
+
74
+ /**
75
+ * @var ModuleManager
64
76
*/
65
77
private $ moduleManager ;
66
78
67
79
/**
68
80
* @param DesignInterface $design
69
81
* @param CollectorInterface $fileSource
70
82
* @param ErrorHandlerInterface $errorHandler
71
- * @param \Magento\Framework\View\Asset\Repository $assetRepo
72
- * @param \Magento\Framework\View\Design\Theme\ListInterface $themeList
73
- * @param \Magento\Framework\Module\Manager|null $moduleManager
83
+ * @param AssetRepository $assetRepo
84
+ * @param ThemeListInterface $themeList
85
+ * @param DeploymentConfig|null $deploymentConfig
86
+ * @param ModuleManager|null $moduleManager
74
87
*/
75
88
public function __construct (
76
89
DesignInterface $ design ,
77
90
CollectorInterface $ fileSource ,
78
91
ErrorHandlerInterface $ errorHandler ,
79
- \Magento \Framework \View \Asset \Repository $ assetRepo ,
80
- \Magento \Framework \View \Design \Theme \ListInterface $ themeList ,
81
- ?\Magento \Framework \Module \Manager $ moduleManager = null
92
+ AssetRepository $ assetRepo ,
93
+ ThemeListInterface $ themeList ,
94
+ ?DeploymentConfig $ deploymentConfig = null ,
95
+ ?ModuleManager $ moduleManager = null
82
96
) {
83
97
$ this ->design = $ design ;
84
98
$ this ->fileSource = $ fileSource ;
85
99
$ this ->errorHandler = $ errorHandler ;
86
100
$ this ->assetRepo = $ assetRepo ;
87
101
$ this ->themeList = $ themeList ;
88
- $ this ->moduleManager = $ moduleManager
89
- ?? ObjectManager::getInstance ()->get (\ Magento \ Framework \ Module \Manager ::class);
102
+ $ this ->deploymentConfig = $ deploymentConfig ?? ObjectManager:: getInstance () -> get (DeploymentConfig::class);
103
+ $ this -> moduleManager = $ moduleManager ?? ObjectManager::getInstance ()->get (ModuleManager ::class);
90
104
}
91
105
92
106
/**
@@ -117,12 +131,12 @@ protected function replace(array $matchedContent, LocalInterface $asset)
117
131
$ relatedAsset = $ this ->assetRepo ->createRelated ($ matchedFileId , $ asset );
118
132
$ resolvedPath = $ relatedAsset ->getFilePath ();
119
133
$ importFiles = $ this ->fileSource ->getFiles ($ this ->getTheme ($ relatedAsset ), $ resolvedPath );
134
+ $ deployOnlyEnabled = (bool )$ this ->deploymentConfig ->get (self ::CONFIG_PATH_SCD_ONLY_ENABLED_MODULES );
120
135
/** @var $importFile \Magento\Framework\View\File */
121
136
foreach ($ importFiles as $ importFile ) {
122
137
$ moduleName = $ importFile ->getModule ();
123
138
124
- if ($ moduleName &&
125
- !$ this ->moduleManager ->isEnabled ($ moduleName )) {
139
+ if ($ moduleName && $ deployOnlyEnabled && !$ this ->moduleManager ->isEnabled ($ moduleName )) {
126
140
continue ;
127
141
}
128
142
@@ -141,7 +155,7 @@ protected function replace(array $matchedContent, LocalInterface $asset)
141
155
* Get theme model based on the information from asset
142
156
*
143
157
* @param LocalInterface $asset
144
- * @return \Magento\Framework\View\Design\ ThemeInterface
158
+ * @return ThemeInterface
145
159
*/
146
160
protected function getTheme (LocalInterface $ asset )
147
161
{
0 commit comments