@@ -135,21 +135,30 @@ protected function replace(array $matchedContent, LocalInterface $asset)
135
135
$ relatedAsset = $ this ->assetRepo ->createRelated ($ matchedFileId , $ asset );
136
136
$ resolvedPath = $ relatedAsset ->getFilePath ();
137
137
$ importFiles = $ this ->fileSource ->getFiles ($ this ->getTheme ($ relatedAsset ), $ resolvedPath );
138
- $ deployOnlyEnabled = ( bool ) $ this ->deploymentConfig -> get ( self :: CONFIG_PATH_SCD_ONLY_ENABLED_MODULES );
138
+ $ deployOnlyEnabled = $ this ->getStaticDeployEnabledModulesFlag ( );
139
139
/** @var $importFile \Magento\Framework\View\File */
140
140
foreach ($ importFiles as $ importFile ) {
141
141
$ moduleName = $ importFile ->getModule ();
142
142
143
- if ($ moduleName && $ deployOnlyEnabled && !$ this ->moduleManager ->isEnabled ($ moduleName )) {
144
- continue ;
145
- }
146
-
147
- if (!$ deployOnlyEnabled || ($ moduleName && $ deployOnlyEnabled && $ this ->moduleManager ->isEnabled ($ moduleName ))) {
143
+ if (!$ deployOnlyEnabled ) {
148
144
$ referenceString = $ isReference ? '(reference) ' : '' ;
149
145
$ importsContent .= $ moduleName
150
146
? "@import $ referenceString' {$ moduleName }:: {$ resolvedPath }'; \n"
151
147
: "@import $ referenceString' {$ matchedFileId }'; \n" ;
152
148
}
149
+
150
+ if ($ deployOnlyEnabled ) {
151
+ if ($ moduleName && !$ this ->moduleManager ->isEnabled ($ moduleName )) {
152
+ continue ;
153
+ }
154
+
155
+ if ($ moduleName && $ this ->moduleManager ->isEnabled ($ moduleName )) {
156
+ $ referenceString = $ isReference ? '(reference) ' : '' ;
157
+ $ importsContent .= $ moduleName
158
+ ? "@import $ referenceString' {$ moduleName }:: {$ resolvedPath }'; \n"
159
+ : "@import $ referenceString' {$ matchedFileId }'; \n" ;
160
+ }
161
+ }
153
162
}
154
163
} catch (\LogicException $ e ) {
155
164
$ this ->errorHandler ->processException ($ e );
@@ -158,6 +167,16 @@ protected function replace(array $matchedContent, LocalInterface $asset)
158
167
return $ importsContent ;
159
168
}
160
169
170
+ /**
171
+ * Retrieve flag deploy enabled modules
172
+ *
173
+ * @return bool
174
+ */
175
+ protected function getStaticDeployEnabledModulesFlag () : bool
176
+ {
177
+ return (bool ) $ this ->deploymentConfig ->get (self ::CONFIG_PATH_SCD_ONLY_ENABLED_MODULES );
178
+ }
179
+
161
180
/**
162
181
* Get theme model based on the information from asset
163
182
*
0 commit comments