Skip to content

Commit 982bed0

Browse files
author
Igor Melnikov
committed
MAGETWO-60442: Add optional SerializerInterface dependency to child classes of \Magento\Framework\Config\Data
Adding SerializerInterface dependency in the constructor
1 parent 2891de9 commit 982bed0

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

lib/internal/Magento/Framework/Interception/PluginList/PluginList.php

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ class PluginList extends Scoped implements InterceptionPluginList
9292
* @param ObjectManagerInterface $objectManager
9393
* @param ClassDefinitions $classDefinitions
9494
* @param array $scopePriorityScheme
95-
* @param string $cacheId
95+
* @param string|null $cacheId
96+
* @param SerializerInterface|null $serializer
9697
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
9798
*/
9899
public function __construct(
@@ -105,9 +106,11 @@ public function __construct(
105106
ObjectManagerInterface $objectManager,
106107
ClassDefinitions $classDefinitions,
107108
array $scopePriorityScheme = ['global'],
108-
$cacheId = 'plugins'
109+
$cacheId = 'plugins',
110+
SerializerInterface $serializer = null
109111
) {
110-
parent::__construct($reader, $configScope, $cache, $cacheId);
112+
$serializer = $serializer ?: $objectManager->get(Serialize::class);
113+
parent::__construct($reader, $configScope, $cache, $cacheId, $serializer);
111114
$this->_omConfig = $omConfig;
112115
$this->_relations = $relations;
113116
$this->_definitions = $definitions;
@@ -277,7 +280,7 @@ protected function _loadScopedData()
277280
$cacheId = implode('|', $this->_scopePriorityScheme) . "|" . $this->_cacheId;
278281
$data = $this->_cache->load($cacheId);
279282
if ($data) {
280-
list($this->_data, $this->_inherited, $this->_processed) = $this->getSerializer()->unserialize($data);
283+
list($this->_data, $this->_inherited, $this->_processed) = $this->serializer->unserialize($data);
281284
foreach ($this->_scopePriorityScheme as $scope) {
282285
$this->_loadedScopes[$scope] = true;
283286
}
@@ -311,7 +314,7 @@ protected function _loadScopedData()
311314
$this->_inheritPlugins($class);
312315
}
313316
$this->_cache->save(
314-
$this->getSerializer()->serialize([$this->_data, $this->_inherited, $this->_processed]),
317+
$this->serializer->serialize([$this->_data, $this->_inherited, $this->_processed]),
315318
$cacheId
316319
);
317320
}
@@ -389,18 +392,4 @@ private function getLogger()
389392
}
390393
return $this->logger;
391394
}
392-
393-
/**
394-
* Get serializer
395-
*
396-
* @return SerializerInterface
397-
* @deprecated
398-
*/
399-
protected function getSerializer()
400-
{
401-
if (null === $this->serializer) {
402-
$this->serializer = \Magento\Framework\App\ObjectManager::getInstance()->get(Serialize::class);
403-
}
404-
return $this->serializer;
405-
}
406395
}

0 commit comments

Comments
 (0)