Skip to content

Commit a903e8c

Browse files
committed
MAGETWO-96463: Add caching to improve admin performance
- refactor fix in \Magento\Framework\Config\View
1 parent 273bb39 commit a903e8c

File tree

1 file changed

+11
-2
lines changed
  • lib/internal/Magento/Framework/Config

1 file changed

+11
-2
lines changed

lib/internal/Magento/Framework/Config/View.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\App\ObjectManager;
1010
use Magento\Framework\Serialize\SerializerInterface;
1111
use Magento\Framework\Serialize\Serializer\Json;
12+
use Magento\Framework\View\DesignInterface;
1213

1314
/**
1415
* View configuration files handler
@@ -44,6 +45,11 @@ class View extends \Magento\Framework\Config\Reader\Filesystem
4445
*/
4546
private $scopedLayoutCache;
4647

48+
/**
49+
* @var DesignInterface
50+
*/
51+
private $design;
52+
4753
/**
4854
* @param FileResolverInterface $fileResolver
4955
* @param ConverterInterface $converter
@@ -56,6 +62,7 @@ class View extends \Magento\Framework\Config\Reader\Filesystem
5662
* @param array $xpath
5763
* @param LayoutCache|null $layoutCache
5864
* @param SerializerInterface|null $serializer
65+
* @param DesignInterface|null $design
5966
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
6067
*/
6168
public function __construct(
@@ -69,7 +76,8 @@ public function __construct(
6976
$defaultScope = 'global',
7077
$xpath = [],
7178
LayoutCache $layoutCache = null,
72-
SerializerInterface $serializer = null
79+
SerializerInterface $serializer = null,
80+
DesignInterface $design = null
7381
) {
7482
$this->xpath = $xpath;
7583
$idAttributes = $this->getIdAttributes();
@@ -86,6 +94,7 @@ public function __construct(
8694
);
8795
$this->layoutCache = $layoutCache ?? ObjectManager::getInstance()->get(LayoutCache::class);
8896
$this->serializer = $serializer ?? ObjectManager::getInstance()->get(Json::class);
97+
$this->design = $design ?? ObjectManager::getInstance()->get(DesignInterface::class);
8998
}
9099

91100
/**
@@ -235,7 +244,7 @@ protected function initData()
235244
public function read($scope = null)
236245
{
237246
$scope = $scope ?: $this->_defaultScope;
238-
$layoutCacheKey = __CLASS__ . '-'. $scope . '-' . $this->_fileName;
247+
$layoutCacheKey = __CLASS__ . '-'. $scope . '-' . $this->_fileName . '-' . $this->design->getArea();
239248
if (!isset($this->scopedLayoutCache[$layoutCacheKey])) {
240249
if ($data = $this->layoutCache->load($layoutCacheKey)) {
241250
$this->scopedLayoutCache[$layoutCacheKey] = $this->serializer->unserialize($data);

0 commit comments

Comments
 (0)