5
5
*/
6
6
namespace Magento \Framework \ObjectManager \Config ;
7
7
8
+ use Magento \Framework \Serialize \SerializerInterface ;
8
9
use Magento \Framework \ObjectManager \ConfigCacheInterface ;
9
10
use Magento \Framework \ObjectManager \DefinitionInterface ;
10
11
use Magento \Framework \ObjectManager \RelationsInterface ;
11
- use Magento \Framework \Serialize \SerializerInterface ;
12
12
13
- /**
14
- * The object manager config
15
- */
16
13
class Config implements \Magento \Framework \ObjectManager \ConfigInterface
17
14
{
18
15
/**
@@ -30,7 +27,7 @@ class Config implements \Magento\Framework\ObjectManager\ConfigInterface
30
27
protected $ _definitions ;
31
28
32
29
/**
33
- * The current cache key
30
+ * Current cache key
34
31
*
35
32
* @var string
36
33
*/
@@ -44,7 +41,7 @@ class Config implements \Magento\Framework\ObjectManager\ConfigInterface
44
41
protected $ _preferences = [];
45
42
46
43
/**
47
- * The list of virtual types
44
+ * Virtual types
48
45
*
49
46
* @var array
50
47
*/
@@ -79,23 +76,18 @@ class Config implements \Magento\Framework\ObjectManager\ConfigInterface
79
76
protected $ _mergedArguments ;
80
77
81
78
/**
82
- * @var SerializerInterface
79
+ * @var \Magento\Framework\Serialize\ SerializerInterface
83
80
*/
84
81
private $ serializer ;
85
82
86
83
/**
87
- * @param RelationsInterface|null $relations
88
- * @param DefinitionInterface|null $definitions
89
- * @param SerializerInterface|null $serializer
84
+ * @param RelationsInterface $relations
85
+ * @param DefinitionInterface $definitions
90
86
*/
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
+ {
96
89
$ this ->_relations = $ relations ?: new \Magento \Framework \ObjectManager \Relations \Runtime ();
97
90
$ this ->_definitions = $ definitions ?: new \Magento \Framework \ObjectManager \Definition \Runtime ();
98
- $ this ->serializer = $ serializer ?: new \Magento \Framework \Serialize \Serializer \Json ();
99
91
}
100
92
101
93
/**
@@ -283,14 +275,14 @@ public function extend(array $configuration)
283
275
// md5() here is not for cryptographic use.
284
276
// phpcs:ignore Magento2.Security.InsecureFunction
285
277
$ this ->_currentCacheKey = md5 (
286
- $ this ->serializer ->serialize (
278
+ $ this ->getSerializer () ->serialize (
287
279
[$ this ->_arguments , $ this ->_nonShared , $ this ->_preferences , $ this ->_virtualTypes ]
288
280
)
289
281
);
290
282
}
291
283
// md5() here is not for cryptographic use.
292
284
// phpcs:ignore Magento2.Security.InsecureFunction
293
- $ key = md5 ($ this ->_currentCacheKey . $ this ->serializer ->serialize ($ configuration ));
285
+ $ key = md5 ($ this ->_currentCacheKey . $ this ->getSerializer () ->serialize ($ configuration ));
294
286
$ cached = $ this ->_cache ->get ($ key );
295
287
if ($ cached ) {
296
288
list (
@@ -343,4 +335,19 @@ public function getPreferences()
343
335
{
344
336
return $ this ->_preferences ;
345
337
}
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
+ }
346
353
}
0 commit comments