Skip to content

Commit 68c5fba

Browse files
author
Jérémie Tabet
committed
Codestyle
1 parent 1e38e59 commit 68c5fba

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/SlmCache/Listener/Cache.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,13 @@ public function attach(EventManagerInterface $events)
7979
public function matchRoute(MvcEvent $e)
8080
{
8181
$match = $this->match($e);
82+
8283
if (null === $match) {
8384
return;
8485
}
8586

8687
$result = $this->fromCache($e, $match);
88+
8789
if ($result instanceof Response) {
8890
return $result;
8991
}
@@ -157,25 +159,24 @@ protected function match(MvcEvent $e)
157159
protected function fromCache(MvcEvent $e, $match)
158160
{
159161
$key = $this->getCacheKey($match);
160-
$config = $match['config'];
161162
$cache = $this->getCache($e);
162163

163164
$response = $e->getResponse();
164-
if ($result = $cache->getItem($key)) {
165+
166+
if (($result = $cache->getItem($key))) {
165167
$response->setContent($result);
166168
$response->getHeaders()->addHeaderLine('X-Slm-Cache', 'Fetch: Hit; route=' . $match['route']);
167-
168169
$e->setParam('cached', true);
170+
169171
return $response;
170-
} else {
171-
$response->getHeaders()->addHeaderLine('X-Slm-Cache', 'Fetch: Miss; route=' . $match['route']);
172172
}
173+
174+
$response->getHeaders()->addHeaderLine('X-Slm-Cache', 'Fetch: Miss; route=' . $match['route']);
173175
}
174176

175177
protected function storeCache(MvcEvent $e, $match)
176178
{
177179
$key = $this->getCacheKey($match);
178-
$config = $match['config'];
179180
$cache = $this->getCache($e);
180181

181182
$response = $e->getResponse();
@@ -185,8 +186,7 @@ protected function storeCache(MvcEvent $e, $match)
185186

186187
protected function getCache(MvcEvent $e)
187188
{
188-
$config = $this->serviceLocator->get('Config');
189-
$config = $config['slm_cache']['cache'];
189+
$config = $this->serviceLocator->get('Config')['slm_cache']['cache'];
190190

191191
if (is_string($config)) {
192192
$cache = $this->serviceLocator->get($config);

0 commit comments

Comments
 (0)