Skip to content

Commit 985a8a1

Browse files
committed
Remove unneeded internal caching of options
1 parent 9e2d1ae commit 985a8a1

File tree

4 files changed

+29
-22
lines changed

4 files changed

+29
-22
lines changed

app/code/Magento/Catalog/Model/Category/Attribute/Source/Layout.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ class Layout extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
1717
*/
1818
protected $pageLayoutBuilder;
1919

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+
2026
/**
2127
* @param \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface $pageLayoutBuilder
2228
*/
@@ -26,14 +32,14 @@ public function __construct(\Magento\Framework\View\Model\PageLayout\Config\Buil
2632
}
2733

2834
/**
29-
* {@inheritdoc}
35+
* @inheritdoc
3036
*/
3137
public function getAllOptions()
3238
{
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;
3844
}
3945
}

app/code/Magento/Catalog/Model/Product/Attribute/Source/Layout.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ class Layout extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
1717
*/
1818
protected $pageLayoutBuilder;
1919

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+
2026
/**
2127
* @param \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface $pageLayoutBuilder
2228
*/
@@ -26,14 +32,14 @@ public function __construct(\Magento\Framework\View\Model\PageLayout\Config\Buil
2632
}
2733

2834
/**
29-
* @return array
35+
* @inheritdoc
3036
*/
3137
public function getAllOptions()
3238
{
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;
3844
}
3945
}

app/code/Magento/Cms/Model/Page/Source/PageLayout.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class PageLayout implements OptionSourceInterface
2020

2121
/**
2222
* @var array
23+
* @deprecated since the cache is now handled by \Magento\Theme\Model\PageLayout\Config\Builder::$configFiles
2324
*/
2425
protected $options;
2526

@@ -34,16 +35,10 @@ public function __construct(BuilderInterface $pageLayoutBuilder)
3435
}
3536

3637
/**
37-
* Get options
38-
*
39-
* @return array
38+
* @inheritdoc
4039
*/
4140
public function toOptionArray()
4241
{
43-
if ($this->options !== null) {
44-
return $this->options;
45-
}
46-
4742
$configOptions = $this->pageLayoutBuilder->getPageLayoutsConfig()->getOptions();
4843
$options = [];
4944
foreach ($configOptions as $key => $value) {
@@ -54,6 +49,6 @@ public function toOptionArray()
5449
}
5550
$this->options = $options;
5651

57-
return $this->options;
52+
return $options;
5853
}
5954
}

app/code/Magento/Theme/Model/PageLayout/Config/Builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct(
4949
}
5050

5151
/**
52-
* @return \Magento\Framework\View\PageLayout\Config
52+
* @inheritdoc
5353
*/
5454
public function getPageLayoutsConfig()
5555
{
@@ -61,7 +61,7 @@ public function getPageLayoutsConfig()
6161
*/
6262
protected function getConfigFiles()
6363
{
64-
if (empty($this->configFiles)) {
64+
if (!$this->configFiles) {
6565
$configFiles = [];
6666
foreach ($this->themeCollection->loadRegisteredThemes() as $theme) {
6767
$configFiles[] = $this->fileCollector->getFilesContent($theme, 'layouts.xml');

0 commit comments

Comments
 (0)