|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| - * Copyright 2015 Adobe |
| 3 | + * Copyright 2025 Adobe |
4 | 4 | * All Rights Reserved.
|
5 | 5 | */
|
6 | 6 |
|
7 | 7 | namespace Magento\Setup\Console\Command;
|
8 | 8 |
|
9 |
| -use Magento\Framework\App\ObjectManager; |
10 |
| -use Magento\Framework\Filesystem\DriverInterface; |
11 |
| -use Magento\Framework\Filesystem\Io\File; |
12 |
| -use Symfony\Component\Console\Input\InputInterface; |
13 |
| -use Symfony\Component\Console\Output\OutputInterface; |
14 |
| -use Magento\Framework\Filesystem; |
15 |
| -use Magento\Framework\App\Filesystem\DirectoryList; |
16 | 9 | use Magento\Framework\App\DeploymentConfig;
|
| 10 | +use Magento\Framework\App\Filesystem\DirectoryList; |
| 11 | +use Magento\Framework\App\Interception\Cache\CompiledConfig; |
| 12 | +use Magento\Framework\App\ObjectManager; |
| 13 | +use Magento\Framework\App\ObjectManager\ConfigWriterInterface; |
17 | 14 | use Magento\Framework\Component\ComponentRegistrar;
|
18 | 15 | use Magento\Framework\Config\ConfigOptionsListConstants;
|
| 16 | +use Magento\Framework\Console\Cli; |
| 17 | +use Magento\Framework\Filesystem; |
| 18 | +use Magento\Framework\Filesystem\DriverInterface; |
| 19 | +use Magento\Framework\Filesystem\Io\File; |
19 | 20 | use Magento\Setup\Model\ObjectManagerProvider;
|
20 | 21 | use Magento\Setup\Module\Di\App\Task\Manager;
|
21 |
| -use Magento\Setup\Module\Di\App\Task\OperationFactory; |
22 | 22 | use Magento\Setup\Module\Di\App\Task\OperationException;
|
| 23 | +use Magento\Setup\Module\Di\App\Task\OperationFactory; |
23 | 24 | use Magento\Setup\Module\Di\App\Task\OperationInterface;
|
| 25 | +use Magento\Setup\Module\Di\Code\Generator\PluginList; |
| 26 | +use Magento\Setup\Module\Di\Code\Reader\ClassesScanner; |
| 27 | +use Magento\Setup\Module\Di\Compiler\Config\Chain\BackslashTrim; |
| 28 | +use Magento\Setup\Module\Di\Compiler\Config\Chain\InterceptorSubstitution; |
| 29 | +use Magento\Setup\Module\Di\Compiler\Config\Chain\PreferencesResolving; |
| 30 | +use Magento\Setup\Module\Di\Compiler\Config\ModificationChain; |
| 31 | +use Magento\Setup\Module\Di\Compiler\Log\Writer\Console; |
24 | 32 | use Symfony\Component\Console\Command\Command;
|
25 | 33 | use Symfony\Component\Console\Helper\ProgressBar;
|
26 |
| -use Magento\Framework\Console\Cli; |
| 34 | +use Symfony\Component\Console\Input\InputInterface; |
| 35 | +use Symfony\Component\Console\Output\OutputInterface; |
27 | 36 |
|
28 | 37 | /**
|
29 | 38 | * Command to run compile in single-tenant mode
|
@@ -156,20 +165,33 @@ protected function execute(InputInterface $input, OutputInterface $output)
|
156 | 165 | }
|
157 | 166 |
|
158 | 167 | $modulePaths = $this->componentRegistrar->getPaths(ComponentRegistrar::MODULE);
|
| 168 | + $moduleStatuses = $this->deploymentConfig->get(ConfigOptionsListConstants::KEY_MODULES); |
| 169 | + if (!$moduleStatuses || !is_array($moduleStatuses)) { |
| 170 | + return Cli::RETURN_FAILURE; |
| 171 | + } |
| 172 | + $enabledModuleStatuses = array_filter($moduleStatuses, function ($enabled) { |
| 173 | + return $enabled === 1; |
| 174 | + }); |
| 175 | + $enabledModules = array_keys($enabledModuleStatuses); |
| 176 | + |
| 177 | + $modulePathsEnabled = array_filter($modulePaths, function ($path, $module) use ($enabledModules) { |
| 178 | + return in_array($module, $enabledModules, true); |
| 179 | + }, ARRAY_FILTER_USE_BOTH); |
| 180 | + |
159 | 181 | $libraryPaths = $this->componentRegistrar->getPaths(ComponentRegistrar::LIBRARY);
|
160 | 182 | $setupPath = $this->directoryList->getPath(DirectoryList::SETUP);
|
161 | 183 | $generationPath = $this->directoryList->getPath(DirectoryList::GENERATED_CODE);
|
162 | 184 |
|
163 | 185 | $this->objectManager->get(\Magento\Framework\App\Cache::class)->clean();
|
164 | 186 | $compiledPathsList = [
|
165 |
| - 'application' => $modulePaths, |
| 187 | + 'application' => $modulePathsEnabled, |
166 | 188 | 'library' => $libraryPaths,
|
167 | 189 | 'setup' => $setupPath,
|
168 | 190 | 'generated_helpers' => $generationPath
|
169 | 191 | ];
|
170 | 192 |
|
171 | 193 | $this->excludedPathsList = [
|
172 |
| - 'application' => $this->getExcludedModulePaths($modulePaths), |
| 194 | + 'application' => $this->getExcludedModulePaths($modulePathsEnabled), |
173 | 195 | 'framework' => $this->getExcludedLibraryPaths($libraryPaths),
|
174 | 196 | 'setup' => $this->getExcludedSetupPaths($setupPath),
|
175 | 197 | ];
|
@@ -207,11 +229,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
|
207 | 229 | $progressBar->display();
|
208 | 230 |
|
209 | 231 | $this->taskManager->process(
|
210 |
| - function (OperationInterface $operation) use ($progressBar) { |
| 232 | + function (OperationInterface $operation) use ($progressBar): void { |
211 | 233 | $progressBar->setMessage($operation->getName() . '...');
|
212 | 234 | $progressBar->display();
|
213 | 235 | },
|
214 |
| - function (OperationInterface $operation) use ($progressBar) { |
| 236 | + function (OperationInterface $operation) use ($progressBar): void { |
215 | 237 | $progressBar->advance();
|
216 | 238 | }
|
217 | 239 | );
|
@@ -327,39 +349,35 @@ private function configureObjectManager(OutputInterface $output)
|
327 | 349 | {
|
328 | 350 | $this->objectManager->configure(
|
329 | 351 | [
|
330 |
| - 'preferences' => [\Magento\Framework\App\ObjectManager\ConfigWriterInterface::class => |
331 |
| - \Magento\Framework\App\ObjectManager\ConfigWriter\Filesystem::class, |
332 |
| - ], \Magento\Setup\Module\Di\Compiler\Config\ModificationChain::class => [ |
| 352 | + 'preferences' => [ConfigWriterInterface::class => ObjectManager\ConfigWriter\Filesystem::class, |
| 353 | + ], ModificationChain::class => [ |
333 | 354 | 'arguments' => [
|
334 | 355 | 'modificationsList' => [
|
335 | 356 | 'BackslashTrim' => [
|
336 |
| - 'instance' => |
337 |
| - \Magento\Setup\Module\Di\Compiler\Config\Chain\BackslashTrim::class |
| 357 | + 'instance' => BackslashTrim::class |
338 | 358 | ],
|
339 | 359 | 'PreferencesResolving' => [
|
340 |
| - 'instance' => |
341 |
| - \Magento\Setup\Module\Di\Compiler\Config\Chain\PreferencesResolving::class |
| 360 | + 'instance' => PreferencesResolving::class |
342 | 361 | ],
|
343 | 362 | 'InterceptorSubstitution' => [
|
344 |
| - 'instance' => |
345 |
| - \Magento\Setup\Module\Di\Compiler\Config\Chain\InterceptorSubstitution::class |
| 363 | + 'instance' => InterceptorSubstitution::class |
346 | 364 | ],
|
347 | 365 | 'InterceptionPreferencesResolving' => [
|
348 |
| - 'instance' => \Magento\Setup\Module\Di\Compiler\Config\Chain\PreferencesResolving::class |
| 366 | + 'instance' => PreferencesResolving::class |
349 | 367 | ],
|
350 | 368 | ]
|
351 | 369 | ]
|
352 |
| - ], \Magento\Setup\Module\Di\Code\Generator\PluginList::class => [ |
| 370 | + ], PluginList::class => [ |
353 | 371 | 'arguments' => [
|
354 | 372 | 'cache' => [
|
355 |
| - 'instance' => \Magento\Framework\App\Interception\Cache\CompiledConfig::class |
| 373 | + 'instance' => CompiledConfig::class |
356 | 374 | ]
|
357 | 375 | ]
|
358 |
| - ], \Magento\Setup\Module\Di\Code\Reader\ClassesScanner::class => [ |
| 376 | + ], ClassesScanner::class => [ |
359 | 377 | 'arguments' => [
|
360 | 378 | 'excludePatterns' => $this->excludedPathsList
|
361 | 379 | ]
|
362 |
| - ], \Magento\Setup\Module\Di\Compiler\Log\Writer\Console::class => [ |
| 380 | + ], Console::class => [ |
363 | 381 | 'arguments' => [
|
364 | 382 | 'output' => $output,
|
365 | 383 | ]
|
|
0 commit comments