55 */
66namespace Magento \Framework \ObjectManager \Config ;
77
8+ use Magento \Framework \Serialize \SerializerInterface ;
89use Magento \Framework \ObjectManager \ConfigCacheInterface ;
910use Magento \Framework \ObjectManager \DefinitionInterface ;
1011use Magento \Framework \ObjectManager \RelationsInterface ;
11- use Magento \Framework \Serialize \SerializerInterface ;
1212
13- /**
14- * The object manager config
15- */
1613class Config implements \Magento \Framework \ObjectManager \ConfigInterface
1714{
1815 /**
@@ -30,7 +27,7 @@ class Config implements \Magento\Framework\ObjectManager\ConfigInterface
3027 protected $ _definitions ;
3128
3229 /**
33- * The current cache key
30+ * Current cache key
3431 *
3532 * @var string
3633 */
@@ -44,7 +41,7 @@ class Config implements \Magento\Framework\ObjectManager\ConfigInterface
4441 protected $ _preferences = [];
4542
4643 /**
47- * The list of virtual types
44+ * Virtual types
4845 *
4946 * @var array
5047 */
@@ -79,23 +76,18 @@ class Config implements \Magento\Framework\ObjectManager\ConfigInterface
7976 protected $ _mergedArguments ;
8077
8178 /**
82- * @var SerializerInterface
79+ * @var \Magento\Framework\Serialize\ SerializerInterface
8380 */
8481 private $ serializer ;
8582
8683 /**
87- * @param RelationsInterface|null $relations
88- * @param DefinitionInterface|null $definitions
89- * @param SerializerInterface|null $serializer
84+ * @param RelationsInterface $relations
85+ * @param DefinitionInterface $definitions
9086 */
91- public function __construct (
92- RelationsInterface $ relations = null ,
93- DefinitionInterface $ definitions = null ,
94- SerializerInterface $ serializer = null
95- ) {
87+ public function __construct (RelationsInterface $ relations = null , DefinitionInterface $ definitions = null )
88+ {
9689 $ this ->_relations = $ relations ?: new \Magento \Framework \ObjectManager \Relations \Runtime ();
9790 $ this ->_definitions = $ definitions ?: new \Magento \Framework \ObjectManager \Definition \Runtime ();
98- $ this ->serializer = $ serializer ?: new \Magento \Framework \Serialize \Serializer \Json ();
9991 }
10092
10193 /**
@@ -283,14 +275,14 @@ public function extend(array $configuration)
283275 // md5() here is not for cryptographic use.
284276 // phpcs:ignore Magento2.Security.InsecureFunction
285277 $ this ->_currentCacheKey = md5 (
286- $ this ->serializer ->serialize (
278+ $ this ->getSerializer () ->serialize (
287279 [$ this ->_arguments , $ this ->_nonShared , $ this ->_preferences , $ this ->_virtualTypes ]
288280 )
289281 );
290282 }
291283 // md5() here is not for cryptographic use.
292284 // phpcs:ignore Magento2.Security.InsecureFunction
293- $ key = md5 ($ this ->_currentCacheKey . $ this ->serializer ->serialize ($ configuration ));
285+ $ key = md5 ($ this ->_currentCacheKey . $ this ->getSerializer () ->serialize ($ configuration ));
294286 $ cached = $ this ->_cache ->get ($ key );
295287 if ($ cached ) {
296288 list (
@@ -343,4 +335,19 @@ public function getPreferences()
343335 {
344336 return $ this ->_preferences ;
345337 }
338+
339+ /**
340+ * Get serializer
341+ *
342+ * @return \Magento\Framework\Serialize\SerializerInterface
343+ * @deprecated 101.0.0
344+ */
345+ private function getSerializer ()
346+ {
347+ if ($ this ->serializer === null ) {
348+ $ this ->serializer = \Magento \Framework \App \ObjectManager::getInstance ()
349+ ->get (SerializerInterface::class);
350+ }
351+ return $ this ->serializer ;
352+ }
346353}
0 commit comments