Skip to content

Fixed bug when static content deploys including static data from disa… #24772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Magento\Framework\View\Design\Theme\ThemeProviderInterface;
use Magento\Framework\View\DesignInterface;
use Magento\Framework\View\File\CollectorInterface;
use Magento\Framework\Module\ModuleManagerInterface;

/**
* @magento_import instruction preprocessor
Expand Down Expand Up @@ -57,25 +58,33 @@ class MagentoImport implements PreProcessorInterface
*/
private $themeProvider;

/**
* @var ModuleManagerInterface
*/
private $moduleManager;

/**
* @param DesignInterface $design
* @param CollectorInterface $fileSource
* @param ErrorHandlerInterface $errorHandler
* @param \Magento\Framework\View\Asset\Repository $assetRepo
* @param \Magento\Framework\View\Design\Theme\ListInterface $themeList
* @param ModuleManagerInterface $moduleManager
*/
public function __construct(
DesignInterface $design,
CollectorInterface $fileSource,
ErrorHandlerInterface $errorHandler,
\Magento\Framework\View\Asset\Repository $assetRepo,
\Magento\Framework\View\Design\Theme\ListInterface $themeList
\Magento\Framework\View\Design\Theme\ListInterface $themeList,
ModuleManagerInterface $moduleManager = null
) {
$this->design = $design;
$this->fileSource = $fileSource;
$this->errorHandler = $errorHandler;
$this->assetRepo = $assetRepo;
$this->themeList = $themeList;
$this->moduleManager = $moduleManager ?: ObjectManager::getInstance()->get(ModuleManagerInterface::class);
}

/**
Expand Down Expand Up @@ -108,6 +117,9 @@ protected function replace(array $matchedContent, LocalInterface $asset)
$importFiles = $this->fileSource->getFiles($this->getTheme($relatedAsset), $resolvedPath);
/** @var $importFile \Magento\Framework\View\File */
foreach ($importFiles as $importFile) {
if ($importFile->getModule() && !$this->moduleManager->isEnabled($importFile->getModule())) {
continue;
}
$referenceString = $isReference ? '(reference) ' : '';
$importsContent .= $importFile->getModule()
? "@import $referenceString'{$importFile->getModule()}::{$resolvedPath}';\n"
Expand Down