|
5 | 5 | */
|
6 | 6 | namespace Magento\Deploy\Strategy;
|
7 | 7 |
|
8 |
| -use Magento\Deploy\Package\PackagePool; |
| 8 | +use Magento\Deploy\Console\DeployStaticOptions as Options; |
9 | 9 | use Magento\Deploy\Package\Package;
|
| 10 | +use Magento\Deploy\Package\PackagePool; |
10 | 11 | use Magento\Deploy\Process\Queue;
|
11 | 12 |
|
12 | 13 | /**
|
@@ -60,12 +61,43 @@ public function deploy(array $options)
|
60 | 61 | $deployedPackages[] = $package;
|
61 | 62 | }
|
62 | 63 |
|
| 64 | + $parentCompilationRequested = $options[Options::NO_PARENT] !== true; |
| 65 | + $includeThemesMap = array_flip($options[Options::THEME] ?? []); |
| 66 | + $excludeThemesMap = array_flip($options[Options::EXCLUDE_THEME] ?? []); |
| 67 | + |
63 | 68 | foreach ($deployedPackages as $package) {
|
64 |
| - $this->queue->add($package); |
| 69 | + if ($parentCompilationRequested |
| 70 | + || $this->canDeployTheme($package->getTheme(), $includeThemesMap, $excludeThemesMap)) { |
| 71 | + $this->queue->add($package); |
| 72 | + } |
65 | 73 | }
|
66 | 74 |
|
67 | 75 | $this->queue->process();
|
68 | 76 |
|
69 | 77 | return $deployedPackages;
|
70 | 78 | }
|
| 79 | + |
| 80 | + /** |
| 81 | + * Verify if specified theme should be deployed |
| 82 | + * |
| 83 | + * @param string $theme |
| 84 | + * @param array $includedThemesMap |
| 85 | + * @param array $excludedEntitiesMap |
| 86 | + * @return bool |
| 87 | + */ |
| 88 | + private function canDeployTheme(string $theme, array $includedThemesMap, array $excludedEntitiesMap): bool |
| 89 | + { |
| 90 | + $includesAllThemes = array_key_exists('all', $includedThemesMap); |
| 91 | + $excludesNoneThemes = array_key_exists('none', $excludedEntitiesMap); |
| 92 | + |
| 93 | + if ($includesAllThemes && $excludesNoneThemes) { |
| 94 | + return true; |
| 95 | + } elseif (!$excludesNoneThemes) { |
| 96 | + return !array_key_exists($theme, $excludedEntitiesMap); |
| 97 | + } elseif (!$includesAllThemes) { |
| 98 | + return array_key_exists($theme, $includedThemesMap); |
| 99 | + } |
| 100 | + |
| 101 | + return true; |
| 102 | + } |
71 | 103 | }
|
0 commit comments