|
3 | 3 | * Copyright © Magento, Inc. All rights reserved.
|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
| 6 | +declare(strict_types=1); |
| 7 | + |
6 | 8 | namespace Magento\Framework\Css\PreProcessor\Instruction;
|
7 | 9 |
|
8 | 10 | use Magento\Framework\App\ObjectManager;
|
@@ -57,25 +59,34 @@ class MagentoImport implements PreProcessorInterface
|
57 | 59 | */
|
58 | 60 | private $themeProvider;
|
59 | 61 |
|
| 62 | + /** |
| 63 | + * @var \Magento\Framework\Module\Manager |
| 64 | + */ |
| 65 | + private $moduleManager; |
| 66 | + |
60 | 67 | /**
|
61 | 68 | * @param DesignInterface $design
|
62 | 69 | * @param CollectorInterface $fileSource
|
63 | 70 | * @param ErrorHandlerInterface $errorHandler
|
64 | 71 | * @param \Magento\Framework\View\Asset\Repository $assetRepo
|
65 | 72 | * @param \Magento\Framework\View\Design\Theme\ListInterface $themeList
|
| 73 | + * @param \Magento\Framework\Module\Manager|null $moduleManager |
66 | 74 | */
|
67 | 75 | public function __construct(
|
68 | 76 | DesignInterface $design,
|
69 | 77 | CollectorInterface $fileSource,
|
70 | 78 | ErrorHandlerInterface $errorHandler,
|
71 | 79 | \Magento\Framework\View\Asset\Repository $assetRepo,
|
72 |
| - \Magento\Framework\View\Design\Theme\ListInterface $themeList |
| 80 | + \Magento\Framework\View\Design\Theme\ListInterface $themeList, |
| 81 | + ?\Magento\Framework\Module\Manager $moduleManager = null |
73 | 82 | ) {
|
74 | 83 | $this->design = $design;
|
75 | 84 | $this->fileSource = $fileSource;
|
76 | 85 | $this->errorHandler = $errorHandler;
|
77 | 86 | $this->assetRepo = $assetRepo;
|
78 | 87 | $this->themeList = $themeList;
|
| 88 | + $this->moduleManager = $moduleManager |
| 89 | + ?? ObjectManager::getInstance()->get(\Magento\Framework\Module\Manager::class); |
79 | 90 | }
|
80 | 91 |
|
81 | 92 | /**
|
@@ -108,9 +119,16 @@ protected function replace(array $matchedContent, LocalInterface $asset)
|
108 | 119 | $importFiles = $this->fileSource->getFiles($this->getTheme($relatedAsset), $resolvedPath);
|
109 | 120 | /** @var $importFile \Magento\Framework\View\File */
|
110 | 121 | foreach ($importFiles as $importFile) {
|
| 122 | + $moduleName = $importFile->getModule(); |
| 123 | + |
| 124 | + if ($moduleName && |
| 125 | + !$this->moduleManager->isEnabled($moduleName)) { |
| 126 | + continue; |
| 127 | + } |
| 128 | + |
111 | 129 | $referenceString = $isReference ? '(reference) ' : '';
|
112 |
| - $importsContent .= $importFile->getModule() |
113 |
| - ? "@import $referenceString'{$importFile->getModule()}::{$resolvedPath}';\n" |
| 130 | + $importsContent .= $moduleName |
| 131 | + ? "@import $referenceString'{$moduleName}::{$resolvedPath}';\n" |
114 | 132 | : "@import $referenceString'{$matchedFileId}';\n";
|
115 | 133 | }
|
116 | 134 | } catch (\LogicException $e) {
|
|
0 commit comments