Skip to content

Commit 43500fb

Browse files
committed
Issue-230: adding varnish
- fixing objectmanager
1 parent c4947ce commit 43500fb

File tree

1 file changed

+8
-18
lines changed
  • lib/internal/Magento/Framework/App/PageCache

1 file changed

+8
-18
lines changed

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

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class Kernel
6969
* @param \Magento\Framework\App\Response\HttpFactory|null $httpFactory
7070
* @param \Magento\Framework\Serialize\SerializerInterface|null $serializer
7171
* @param AppState|null $state
72+
* @param \Magento\PageCache\Model\Cache\Type $fullPageCache
7273
*/
7374
public function __construct(
7475
\Magento\Framework\App\PageCache\Cache $cache,
@@ -78,7 +79,8 @@ public function __construct(
7879
\Magento\Framework\App\Http\ContextFactory $contextFactory = null,
7980
\Magento\Framework\App\Response\HttpFactory $httpFactory = null,
8081
\Magento\Framework\Serialize\SerializerInterface $serializer = null,
81-
AppState $state = null
82+
AppState $state = null,
83+
\Magento\PageCache\Model\Cache\Type $fullPageCache = null
8284
) {
8385
$this->cache = $cache;
8486
$this->identifier = $identifier;
@@ -94,6 +96,9 @@ public function __construct(
9496
\Magento\Framework\Serialize\SerializerInterface::class
9597
);
9698
$this->state = $state ?? ObjectManager::getInstance()->get(AppState::class);
99+
$this->fullPageCache = $fullPageCache ?? ObjectManager::getInstance()->get(
100+
\Magento\PageCache\Model\Cache\Type::class
101+
);
97102
}
98103

99104
/**
@@ -104,7 +109,7 @@ public function __construct(
104109
public function load()
105110
{
106111
if ($this->request->isGet() || $this->request->isHead()) {
107-
$responseData = $this->getCache()->load($this->identifier->getValue());
112+
$responseData = $this->fullPageCache->load($this->identifier->getValue());
108113
if (!$responseData) {
109114
return false;
110115
}
@@ -143,7 +148,7 @@ public function process(\Magento\Framework\App\Response\Http $response)
143148
header_remove('Set-Cookie');
144149
}
145150

146-
$this->getCache()->save(
151+
$this->fullPageCache->save(
147152
$this->serializer->serialize($this->getPreparedData($response)),
148153
$this->identifier->getValue(),
149154
$tags,
@@ -197,19 +202,4 @@ private function buildResponse($responseData)
197202

198203
return $response;
199204
}
200-
201-
/**
202-
* TODO: Workaround to support backwards compatibility, will rework to use Dependency Injection in MAGETWO-49547
203-
*
204-
* @return \Magento\PageCache\Model\Cache\Type
205-
*/
206-
private function getCache()
207-
{
208-
if (!$this->fullPageCache) {
209-
$this->fullPageCache = ObjectManager::getInstance()->get(
210-
\Magento\PageCache\Model\Cache\Type::class
211-
);
212-
}
213-
return $this->fullPageCache;
214-
}
215205
}

0 commit comments

Comments
 (0)