From 982bed00678e5bfc90811e54528d7b19a1e6d98a Mon Sep 17 00:00:00 2001
From: Igor Melnikov <imelnikov@magento.com>
Date: Thu, 3 Nov 2016 10:32:44 -0500
Subject: [PATCH] MAGETWO-60442: Add optional SerializerInterface dependency to
 child classes of \Magento\Framework\Config\Data

Adding SerializerInterface dependency in the constructor
---
 .../Interception/PluginList/PluginList.php    | 27 ++++++-------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php b/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php
index 3406a139567..f74213eaf4a 100644
--- a/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php
+++ b/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php
@@ -92,7 +92,8 @@ class PluginList extends Scoped implements InterceptionPluginList
      * @param ObjectManagerInterface $objectManager
      * @param ClassDefinitions $classDefinitions
      * @param array $scopePriorityScheme
-     * @param string $cacheId
+     * @param string|null $cacheId
+     * @param SerializerInterface|null $serializer
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
     public function __construct(
@@ -105,9 +106,11 @@ class PluginList extends Scoped implements InterceptionPluginList
         ObjectManagerInterface $objectManager,
         ClassDefinitions $classDefinitions,
         array $scopePriorityScheme = ['global'],
-        $cacheId = 'plugins'
+        $cacheId = 'plugins',
+        SerializerInterface $serializer = null
     ) {
-        parent::__construct($reader, $configScope, $cache, $cacheId);
+        $serializer = $serializer ?: $objectManager->get(Serialize::class);
+        parent::__construct($reader, $configScope, $cache, $cacheId, $serializer);
         $this->_omConfig = $omConfig;
         $this->_relations = $relations;
         $this->_definitions = $definitions;
@@ -277,7 +280,7 @@ class PluginList extends Scoped implements InterceptionPluginList
             $cacheId = implode('|', $this->_scopePriorityScheme) . "|" . $this->_cacheId;
             $data = $this->_cache->load($cacheId);
             if ($data) {
-                list($this->_data, $this->_inherited, $this->_processed) = $this->getSerializer()->unserialize($data);
+                list($this->_data, $this->_inherited, $this->_processed) = $this->serializer->unserialize($data);
                 foreach ($this->_scopePriorityScheme as $scope) {
                     $this->_loadedScopes[$scope] = true;
                 }
@@ -311,7 +314,7 @@ class PluginList extends Scoped implements InterceptionPluginList
                     $this->_inheritPlugins($class);
                 }
                 $this->_cache->save(
-                    $this->getSerializer()->serialize([$this->_data, $this->_inherited, $this->_processed]),
+                    $this->serializer->serialize([$this->_data, $this->_inherited, $this->_processed]),
                     $cacheId
                 );
             }
@@ -389,18 +392,4 @@ class PluginList extends Scoped implements InterceptionPluginList
         }
         return $this->logger;
     }
-
-    /**
-     * Get serializer
-     *
-     * @return SerializerInterface
-     * @deprecated
-     */
-    protected function getSerializer()
-    {
-        if (null === $this->serializer) {
-            $this->serializer = \Magento\Framework\App\ObjectManager::getInstance()->get(Serialize::class);
-        }
-        return $this->serializer;
-    }
 }
-- 
GitLab