File tree Expand file tree Collapse file tree 5 files changed +43
-26
lines changed
Category/Attribute/Source
Test/Unit/Model/PageLayout/Config Expand file tree Collapse file tree 5 files changed +43
-26
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,12 @@ class Layout extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
17
17
*/
18
18
protected $ pageLayoutBuilder ;
19
19
20
+ /**
21
+ * @inheritdoc
22
+ * @deprecated since the cache is now handled by \Magento\Theme\Model\PageLayout\Config\Builder::$configFiles
23
+ */
24
+ protected $ _options = null ;
25
+
20
26
/**
21
27
* @param \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface $pageLayoutBuilder
22
28
*/
@@ -26,14 +32,14 @@ public function __construct(\Magento\Framework\View\Model\PageLayout\Config\Buil
26
32
}
27
33
28
34
/**
29
- * { @inheritdoc}
35
+ * @inheritdoc
30
36
*/
31
37
public function getAllOptions ()
32
38
{
33
- if (! $ this ->_options ) {
34
- $ this -> _options = $ this -> pageLayoutBuilder -> getPageLayoutsConfig ()-> toOptionArray ( );
35
- array_unshift ( $ this ->_options , [ ' value ' => '' , ' label ' => __ ( ' No layout updates ' )]) ;
36
- }
37
- return $ this -> _options ;
39
+ $ options = $ this ->pageLayoutBuilder -> getPageLayoutsConfig ()-> toOptionArray ();
40
+ array_unshift ( $ options , [ ' value ' => '' , ' label ' => __ ( ' No layout updates ' )] );
41
+ $ this ->_options = $ options ;
42
+
43
+ return $ options ;
38
44
}
39
45
}
Original file line number Diff line number Diff line change @@ -17,6 +17,12 @@ class Layout extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
17
17
*/
18
18
protected $ pageLayoutBuilder ;
19
19
20
+ /**
21
+ * @inheritdoc
22
+ * @deprecated since the cache is now handled by \Magento\Theme\Model\PageLayout\Config\Builder::$configFiles
23
+ */
24
+ protected $ _options = null ;
25
+
20
26
/**
21
27
* @param \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface $pageLayoutBuilder
22
28
*/
@@ -26,14 +32,14 @@ public function __construct(\Magento\Framework\View\Model\PageLayout\Config\Buil
26
32
}
27
33
28
34
/**
29
- * @return array
35
+ * @inheritdoc
30
36
*/
31
37
public function getAllOptions ()
32
38
{
33
- if (! $ this ->_options ) {
34
- $ this -> _options = $ this -> pageLayoutBuilder -> getPageLayoutsConfig ()-> toOptionArray ( );
35
- array_unshift ( $ this ->_options , [ ' value ' => '' , ' label ' => __ ( ' No layout updates ' )]) ;
36
- }
37
- return $ this -> _options ;
39
+ $ options = $ this ->pageLayoutBuilder -> getPageLayoutsConfig ()-> toOptionArray ();
40
+ array_unshift ( $ options , [ ' value ' => '' , ' label ' => __ ( ' No layout updates ' )] );
41
+ $ this ->_options = $ options ;
42
+
43
+ return $ options ;
38
44
}
39
45
}
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ class PageLayout implements OptionSourceInterface
20
20
21
21
/**
22
22
* @var array
23
+ * @deprecated since the cache is now handled by \Magento\Theme\Model\PageLayout\Config\Builder::$configFiles
23
24
*/
24
25
protected $ options ;
25
26
@@ -34,16 +35,10 @@ public function __construct(BuilderInterface $pageLayoutBuilder)
34
35
}
35
36
36
37
/**
37
- * Get options
38
- *
39
- * @return array
38
+ * @inheritdoc
40
39
*/
41
40
public function toOptionArray ()
42
41
{
43
- if ($ this ->options !== null ) {
44
- return $ this ->options ;
45
- }
46
-
47
42
$ configOptions = $ this ->pageLayoutBuilder ->getPageLayoutsConfig ()->getOptions ();
48
43
$ options = [];
49
44
foreach ($ configOptions as $ key => $ value ) {
@@ -54,6 +49,6 @@ public function toOptionArray()
54
49
}
55
50
$ this ->options = $ options ;
56
51
57
- return $ this -> options ;
52
+ return $ options ;
58
53
}
59
54
}
Original file line number Diff line number Diff line change @@ -27,6 +27,11 @@ class Builder implements \Magento\Framework\View\Model\PageLayout\Config\Builder
27
27
*/
28
28
protected $ themeCollection ;
29
29
30
+ /**
31
+ * @var array
32
+ */
33
+ private $ configFiles = [];
34
+
30
35
/**
31
36
* @param \Magento\Framework\View\PageLayout\ConfigFactory $configFactory
32
37
* @param \Magento\Framework\View\PageLayout\File\Collector\Aggregated $fileCollector
@@ -44,23 +49,28 @@ public function __construct(
44
49
}
45
50
46
51
/**
47
- * @return \Magento\Framework\View\PageLayout\Config
52
+ * @inheritdoc
48
53
*/
49
54
public function getPageLayoutsConfig ()
50
55
{
51
56
return $ this ->configFactory ->create (['configFiles ' => $ this ->getConfigFiles ()]);
52
57
}
53
58
54
59
/**
60
+ * Retrieve configuration files.
61
+ *
55
62
* @return array
56
63
*/
57
64
protected function getConfigFiles ()
58
65
{
59
- $ configFiles = [];
60
- foreach ($ this ->themeCollection ->loadRegisteredThemes () as $ theme ) {
61
- $ configFiles = array_merge ($ configFiles , $ this ->fileCollector ->getFilesContent ($ theme , 'layouts.xml ' ));
66
+ if (!$ this ->configFiles ) {
67
+ $ configFiles = [];
68
+ foreach ($ this ->themeCollection ->loadRegisteredThemes () as $ theme ) {
69
+ $ configFiles [] = $ this ->fileCollector ->getFilesContent ($ theme , 'layouts.xml ' );
70
+ }
71
+ $ this ->configFiles = array_merge (...$ configFiles );
62
72
}
63
73
64
- return $ configFiles ;
74
+ return $ this -> configFiles ;
65
75
}
66
76
}
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ public function testGetPageLayoutsConfig()
83
83
->disableOriginalConstructor ()
84
84
->getMock ();
85
85
86
- $ this ->themeCollection ->expects ($ this ->any ())
86
+ $ this ->themeCollection ->expects ($ this ->once ())
87
87
->method ('loadRegisteredThemes ' )
88
88
->willReturn ([$ theme1 , $ theme2 ]);
89
89
You can’t perform that action at this time.
0 commit comments