5
5
*/
6
6
namespace Magento \Customer \Model \Customer ;
7
7
8
+ use Magento \Framework \App \ObjectManager ;
8
9
use Magento \Framework \Cache \FrontendInterface ;
9
10
use Magento \Framework \Serialize \SerializerInterface ;
10
11
@@ -18,21 +19,21 @@ class NotificationStorage
18
19
private $ cache ;
19
20
20
21
/**
21
- * @param FrontendInterface $cache
22
- */
23
-
24
- /**
25
- * @param FrontendInterface $cache
22
+ * @var SerializerInterface
26
23
*/
27
24
private $ serializer ;
28
25
29
26
/**
30
27
* NotificationStorage constructor.
31
28
* @param FrontendInterface $cache
29
+ * @param SerializerInterface $serializer
32
30
*/
33
- public function __construct (FrontendInterface $ cache )
34
- {
31
+ public function __construct (
32
+ FrontendInterface $ cache ,
33
+ SerializerInterface $ serializer = null
34
+ ) {
35
35
$ this ->cache = $ cache ;
36
+ $ this ->serializer = $ serializer ?: ObjectManager::getInstance ()->get (SerializerInterface::class);
36
37
}
37
38
38
39
/**
@@ -45,7 +46,7 @@ public function __construct(FrontendInterface $cache)
45
46
public function add ($ notificationType , $ customerId )
46
47
{
47
48
$ this ->cache ->save (
48
- $ this ->getSerializer () ->serialize ([
49
+ $ this ->serializer ->serialize ([
49
50
'customer_id ' => $ customerId ,
50
51
'notification_type ' => $ notificationType
51
52
]),
@@ -88,19 +89,4 @@ private function getCacheKey($notificationType, $customerId)
88
89
{
89
90
return 'notification_ ' . $ notificationType . '_ ' . $ customerId ;
90
91
}
91
-
92
- /**
93
- * Get serializer
94
- *
95
- * @return SerializerInterface
96
- * @deprecated 100.2.0
97
- */
98
- private function getSerializer ()
99
- {
100
- if ($ this ->serializer === null ) {
101
- $ this ->serializer = \Magento \Framework \App \ObjectManager::getInstance ()
102
- ->get (SerializerInterface::class);
103
- }
104
- return $ this ->serializer ;
105
- }
106
92
}
0 commit comments