Skip to content

Commit 346dcef

Browse files
committed
MAGETWO-62514: Remove uses of serialize/unserialize in \Magento\Framework\App\PageCache\Kernel
1 parent a22a6b5 commit 346dcef

File tree

1 file changed

+44
-23
lines changed
  • lib/internal/Magento/Framework/App/PageCache

1 file changed

+44
-23
lines changed

lib/internal/Magento/Framework/App/PageCache/Kernel.php

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55
*/
66
namespace Magento\Framework\App\PageCache;
77

8-
use Magento\Framework\App\ObjectManager;
9-
use Magento\Framework\Serialize\SerializerInterface;
10-
use Magento\Framework\App\Http\Context;
11-
use Magento\Framework\App\Http\ContextFactory;
12-
use Magento\Framework\App\Response\HttpFactory;
13-
148
/**
159
* Builtin cache processor
1610
*/
@@ -39,50 +33,75 @@ class Kernel
3933
private $fullPageCache;
4034

4135
/**
42-
* @var SerializerInterface
36+
* @var \Magento\Framework\Serialize\SerializerInterface
4337
*/
4438
private $serializer;
4539

4640
/**
47-
* @var Context
41+
* @var \Magento\Framework\App\Http\Context
4842
*/
4943
private $context;
5044

5145
/**
52-
* @var ContextFactory
46+
* @var \Magento\Framework\App\Http\ContextFactory
5347
*/
5448
private $contextFactory;
5549

5650
/**
57-
* @var HttpFactory
51+
* @var \Magento\Framework\App\Response\HttpFactory
5852
*/
5953
private $httpFactory;
6054

6155
/**
6256
* @param Cache $cache
6357
* @param Identifier $identifier
6458
* @param \Magento\Framework\App\Request\Http $request
65-
* @param Context|null $context
66-
* @param ContextFactory|null $contextFactory
67-
* @param HttpFactory|null $httpFactory
68-
* @param SerializerInterface|null $serializer
59+
* @param \Magento\Framework\App\Http\Context|null $context
60+
* @param \Magento\Framework\App\Http\ContextFactory|null $contextFactory
61+
* @param \Magento\Framework\App\Response\HttpFactory|null $httpFactory
62+
* @param \Magento\Framework\Serialize\SerializerInterface|null $serializer
6963
*/
7064
public function __construct(
7165
\Magento\Framework\App\PageCache\Cache $cache,
7266
\Magento\Framework\App\PageCache\Identifier $identifier,
7367
\Magento\Framework\App\Request\Http $request,
74-
Context $context = null,
75-
ContextFactory $contextFactory = null,
76-
HttpFactory $httpFactory = null,
77-
SerializerInterface $serializer = null
68+
\Magento\Framework\App\Http\Context $context = null,
69+
\Magento\Framework\App\Http\ContextFactory $contextFactory = null,
70+
\Magento\Framework\App\Response\HttpFactory $httpFactory = null,
71+
\Magento\Framework\Serialize\SerializerInterface $serializer = null
7872
) {
7973
$this->cache = $cache;
8074
$this->identifier = $identifier;
8175
$this->request = $request;
82-
$this->context = $context ?: ObjectManager::getInstance()->get(Context::class);
83-
$this->contextFactory = $contextFactory ?: ObjectManager::getInstance()->get(ContextFactory::class);
84-
$this->httpFactory = $httpFactory ?: ObjectManager::getInstance()->get(HttpFactory::class);
85-
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
76+
77+
if ($context) {
78+
$this->context = $context;
79+
} else {
80+
$this->context = \Magento\Framework\App\ObjectManager::getInstance()->get(
81+
\Magento\Framework\App\Http\Context::class
82+
);
83+
}
84+
if ($contextFactory) {
85+
$this->contextFactory = $contextFactory;
86+
} else {
87+
$this->contextFactory = \Magento\Framework\App\ObjectManager::getInstance()->get(
88+
\Magento\Framework\App\Http\ContextFactory::class
89+
);
90+
}
91+
if ($httpFactory) {
92+
$this->httpFactory = $httpFactory;
93+
} else {
94+
$this->httpFactory = \Magento\Framework\App\ObjectManager::getInstance()->get(
95+
\Magento\Framework\App\Response\HttpFactory::class
96+
);
97+
}
98+
if ($serializer) {
99+
$this->serializer = $serializer;
100+
} else {
101+
$this->serializer = \Magento\Framework\App\ObjectManager::getInstance()->get(
102+
\Magento\Framework\Serialize\SerializerInterface::class
103+
);
104+
}
86105
}
87106

88107
/**
@@ -190,7 +209,9 @@ private function buildResponse($responseData)
190209
private function getCache()
191210
{
192211
if (!$this->fullPageCache) {
193-
$this->fullPageCache = ObjectManager::getInstance()->get(\Magento\PageCache\Model\Cache\Type::class);
212+
$this->fullPageCache = \Magento\Framework\App\ObjectManager::getInstance()->get(
213+
\Magento\PageCache\Model\Cache\Type::class
214+
);
194215
}
195216
return $this->fullPageCache;
196217
}

0 commit comments

Comments
 (0)