Skip to content

Commit 2c8fe5c

Browse files
author
Stanislav Idolov
authored
ENGCOM-1576: [Forwardport] Fix \Magento\Customer\Model\Customer\NotificationStorage class #15263
2 parents b21927f + c4be9d8 commit 2c8fe5c

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

app/code/Magento/Customer/Model/Customer/NotificationStorage.php

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Customer\Model\Customer;
77

8+
use Magento\Framework\App\ObjectManager;
89
use Magento\Framework\Cache\FrontendInterface;
910
use Magento\Framework\Serialize\SerializerInterface;
1011

@@ -18,21 +19,21 @@ class NotificationStorage
1819
private $cache;
1920

2021
/**
21-
* @param FrontendInterface $cache
22-
*/
23-
24-
/**
25-
* @param FrontendInterface $cache
22+
* @var SerializerInterface
2623
*/
2724
private $serializer;
2825

2926
/**
3027
* NotificationStorage constructor.
3128
* @param FrontendInterface $cache
29+
* @param SerializerInterface $serializer
3230
*/
33-
public function __construct(FrontendInterface $cache)
34-
{
31+
public function __construct(
32+
FrontendInterface $cache,
33+
SerializerInterface $serializer = null
34+
) {
3535
$this->cache = $cache;
36+
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
3637
}
3738

3839
/**
@@ -45,7 +46,7 @@ public function __construct(FrontendInterface $cache)
4546
public function add($notificationType, $customerId)
4647
{
4748
$this->cache->save(
48-
$this->getSerializer()->serialize([
49+
$this->serializer->serialize([
4950
'customer_id' => $customerId,
5051
'notification_type' => $notificationType
5152
]),
@@ -88,19 +89,4 @@ private function getCacheKey($notificationType, $customerId)
8889
{
8990
return 'notification_' . $notificationType . '_' . $customerId;
9091
}
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-
}
10692
}

0 commit comments

Comments
 (0)