Skip to content

Commit

Permalink
Avoid duplicate loading of configuration files
Browse files Browse the repository at this point in the history
  • Loading branch information
ajardin authored and Amol Chaudhari committed Jan 27, 2019
1 parent 78182ac commit bf13289
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions app/code/Magento/Theme/Model/PageLayout/Config/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class Builder implements \Magento\Framework\View\Model\PageLayout\Config\Builder
*/
protected $themeCollection;

/**
* @var array
*/
private $configFiles = [];

/**
* @param \Magento\Framework\View\PageLayout\ConfigFactory $configFactory
* @param \Magento\Framework\View\PageLayout\File\Collector\Aggregated $fileCollector
Expand Down Expand Up @@ -56,11 +61,14 @@ public function getPageLayoutsConfig()
*/
protected function getConfigFiles()
{
$configFiles = [];
foreach ($this->themeCollection->loadRegisteredThemes() as $theme) {
$configFiles = array_merge($configFiles, $this->fileCollector->getFilesContent($theme, 'layouts.xml'));
if (empty($this->configFiles)) {
$configFiles = [];
foreach ($this->themeCollection->loadRegisteredThemes() as $theme) {
$configFiles[] = $this->fileCollector->getFilesContent($theme, 'layouts.xml');
}
$this->configFiles = array_merge(...$configFiles);
}

return $configFiles;
return $this->configFiles;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function testGetPageLayoutsConfig()
->disableOriginalConstructor()
->getMock();

$this->themeCollection->expects($this->any())
$this->themeCollection->expects($this->once())
->method('loadRegisteredThemes')
->willReturn([$theme1, $theme2]);

Expand Down

0 comments on commit bf13289

Please sign in to comment.