Skip to content

Commit d060ce6

Browse files
committed
Speedup static content deploy for specific theme
Add support for standard strategy
1 parent 81c40a5 commit d060ce6

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

app/code/Magento/Deploy/Console/DeployStaticOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ private function getSkipOptions()
334334
self::NO_PARENT,
335335
null,
336336
InputOption::VALUE_NONE,
337-
'Do not compile parent themes. Supported only in quick strategy.'
337+
'Do not compile parent themes. Supported only in quick and standard strategies.'
338338
),
339339
];
340340
}

app/code/Magento/Deploy/Console/InputValidator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ private function checkNoParentInput(bool $noParent, string $strategy): void
205205
{
206206
$supportedStrategies = [
207207
'quick' => true,
208+
'standard' => true,
208209
];
209210

210211
if ($noParent && !array_key_exists($strategy, $supportedStrategies)) {

app/code/Magento/Deploy/Strategy/StandardDeploy.php

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
*/
66
namespace Magento\Deploy\Strategy;
77

8-
use Magento\Deploy\Package\PackagePool;
8+
use Magento\Deploy\Console\DeployStaticOptions as Options;
99
use Magento\Deploy\Package\Package;
10+
use Magento\Deploy\Package\PackagePool;
1011
use Magento\Deploy\Process\Queue;
1112

1213
/**
@@ -60,12 +61,43 @@ public function deploy(array $options)
6061
$deployedPackages[] = $package;
6162
}
6263

64+
$parentCompilationRequested = $options[Options::NO_PARENT] !== true;
65+
$includeThemesMap = array_flip($options[Options::THEME] ?? []);
66+
$excludeThemesMap = array_flip($options[Options::EXCLUDE_THEME] ?? []);
67+
6368
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+
}
6573
}
6674

6775
$this->queue->process();
6876

6977
return $deployedPackages;
7078
}
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+
}
71103
}

0 commit comments

Comments
 (0)