Skip to content

Commit 8a7fb43

Browse files
committed
MAGETWO-38561: Exceptions when publishing static files in production mode
- removed duplicated logic - reusing Theme model logic
1 parent e1057f6 commit 8a7fb43

File tree

1 file changed

+9
-38
lines changed

1 file changed

+9
-38
lines changed

setup/src/Magento/Setup/Model/Deployer.php

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66

77
namespace Magento\Setup\Model;
88

9-
use Magento\Framework\App\Filesystem\DirectoryList;
109
use Magento\Framework\App\ObjectManagerFactory;
1110
use Magento\Framework\App\View\Deployment\Version;
1211
use Magento\Framework\App\View\Asset\Publisher;
1312
use Magento\Framework\App\Utility\Files;
1413
use Magento\Framework\Config\Theme;
15-
use Magento\Framework\Filesystem;
1614
use Magento\Framework\ObjectManagerInterface;
1715
use Magento\Framework\Translate\Js\Config as JsTranslationConfig;
1816
use Symfony\Component\Console\Output\OutputInterface;
@@ -24,11 +22,6 @@
2422
*/
2523
class Deployer
2624
{
27-
/**
28-
* @var Filesystem
29-
*/
30-
private $filesystem;
31-
3225
/** @var Files */
3326
private $filesUtil;
3427

@@ -78,14 +71,8 @@ class Deployer
7871
*/
7972
protected $jsTranslationConfig;
8073

81-
/**
82-
* @var \Magento\Framework\View\Design\ThemeInterface[]
83-
*/
84-
private $parentTheme;
85-
8674
/**
8775
* @param Files $filesUtil
88-
* @param Filesystem $filesystem
8976
* @param OutputInterface $output
9077
* @param Version\StorageInterface $versionStorage
9178
* @param \Magento\Framework\Stdlib\DateTime $dateTime
@@ -95,15 +82,13 @@ class Deployer
9582
*/
9683
public function __construct(
9784
Files $filesUtil,
98-
Filesystem $filesystem,
9985
OutputInterface $output,
10086
Version\StorageInterface $versionStorage,
10187
\Magento\Framework\Stdlib\DateTime $dateTime,
10288
\Magento\Framework\View\Asset\MinifyService $minifyService,
10389
JsTranslationConfig $jsTranslationConfig,
10490
$isDryRun = false
10591
) {
106-
$this->filesystem = $filesystem;
10792
$this->filesUtil = $filesUtil;
10893
$this->output = $output;
10994
$this->versionStorage = $versionStorage;
@@ -326,36 +311,22 @@ private function deployFile($filePath, $area, $themePath, $locale, $module)
326311
}
327312

328313
/**
329-
* Find ancestor themes
314+
* Find ancestor themes' full paths
330315
*
331316
* @param string $themeFullPath
332317
* @return string[]
333318
*/
334319
private function findAncestors($themeFullPath)
335320
{
336-
$ancestors = [];
337-
if (!isset($this->parentTheme[$themeFullPath])) {
338-
/** @var \Magento\Framework\View\Design\Theme\ListInterface $themeCollection */
339-
$themeCollection = $this->objectManager->get('Magento\Framework\View\Design\Theme\ListInterface');
340-
$theme = $themeCollection->getThemeByFullPath($themeFullPath);
341-
$parentTheme = $theme->getParentTheme();
342-
if ($parentTheme) {
343-
$this->parentTheme[$themeFullPath] = $parentTheme;
344-
$ancestors[] = $parentTheme->getFullPath();
345-
$ancestors = array_merge(
346-
$ancestors,
347-
$this->findAncestors($parentTheme->getFullPath())
348-
);
349-
}
350-
} else {
351-
$parentTheme = $this->parentTheme[$themeFullPath];
352-
$ancestors[] = $parentTheme->getFullPath();
353-
$ancestors = array_merge(
354-
$ancestors,
355-
$this->findAncestors($parentTheme->getFullPath())
356-
);
321+
/** @var \Magento\Framework\View\Design\Theme\ListInterface $themeCollection */
322+
$themeCollection = $this->objectManager->get('Magento\Framework\View\Design\Theme\ListInterface');
323+
$theme = $themeCollection->getThemeByFullPath($themeFullPath);
324+
$ancestors = $theme->getInheritedThemes();
325+
$ancestorThemeFullPath = [];
326+
foreach ($ancestors as $ancestor) {
327+
$ancestorThemeFullPath[] = $ancestor->getFullPath();
357328
}
358-
return $ancestors;
329+
return $ancestorThemeFullPath;
359330
}
360331

361332
/**

0 commit comments

Comments
 (0)