Skip to content

Commit

Permalink
Remove hard cache
Browse files Browse the repository at this point in the history
  • Loading branch information
ZAYEC77 committed May 24, 2016
1 parent 5928926 commit 32c035c
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions src/actions/PageView.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use nullref\cms\models\Page;
use Yii;
use yii\base\Action;
use yii\caching\Cache;
use yii\web\NotFoundHttpException;


Expand All @@ -16,9 +15,7 @@
class PageView extends Action
{
public $view = 'view';

public $cachePrefix = 'cms.page.';


public function run()
{
if (($route = Yii::$app->request->getQueryParam('route')) == null) {
Expand All @@ -32,22 +29,16 @@ public function run()
throw new NotFoundHttpException(Yii::t('cms', 'Page not found.'));
}

/** @var Cache $cache */
$cache = Yii::$app->getCache();

if (($result = $cache->get($this->cachePrefix . $route)) === false) {
if ($page->layout) {
$this->controller->layout = $page->layout;
}
if ($page->type == Page::TYPE_CONTENT) {
$this->view = 'content-view';
}
$result = $this->controller->render($this->view, [
'page' => $page,
]);
$cache->set($this->cachePrefix . $route, $result);
if ($page->layout) {
$this->controller->layout = $page->layout;
}
if ($page->type == Page::TYPE_CONTENT) {
$this->view = 'content-view';
}
$result = $this->controller->render($this->view, [
'page' => $page,
]);

return $result;
}
}
}

0 comments on commit 32c035c

Please sign in to comment.