1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
* Magento validator config factory
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Theme\Model\PageLayout\Config;
/**
* Page layout config builder
*/
class Builder implements \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface
{
/**
* @var \Magento\Framework\View\PageLayout\ConfigFactory
*/
protected $configFactory;
/**
* @var \Magento\Framework\View\PageLayout\File\Collector\Aggregated
*/
protected $fileCollector;
/**
* @var \Magento\Theme\Model\ResourceModel\Theme\Collection
*/
protected $themeCollection;
/**
* @var array
*/
private $configFiles = [];
/**
* @param \Magento\Framework\View\PageLayout\ConfigFactory $configFactory
* @param \Magento\Framework\View\PageLayout\File\Collector\Aggregated $fileCollector
* @param \Magento\Theme\Model\ResourceModel\Theme\Collection $themeCollection
*/
public function __construct(
\Magento\Framework\View\PageLayout\ConfigFactory $configFactory,
\Magento\Framework\View\PageLayout\File\Collector\Aggregated $fileCollector,
\Magento\Theme\Model\ResourceModel\Theme\Collection $themeCollection
) {
$this->configFactory = $configFactory;
$this->fileCollector = $fileCollector;
$this->themeCollection = $themeCollection;
$this->themeCollection->setItemObjectClass(\Magento\Theme\Model\Theme\Data::class);
}
/**
* @inheritdoc
*/
public function getPageLayoutsConfig()
{
return $this->configFactory->create(['configFiles' => $this->getConfigFiles()]);
}
/**
* Retrieve configuration files.
*
* @return array
*/
protected function getConfigFiles()
{
if (!$this->configFiles) {
$configFiles = [];
foreach ($this->themeCollection->loadRegisteredThemes() as $theme) {
$configFiles[] = $this->fileCollector->getFilesContent($theme, 'layouts.xml');
}
$this->configFiles = array_merge(...$configFiles);
}
return $this->configFiles;
}
}