Skip to content

Commit 5f0dec2

Browse files
committed
fixes
1 parent c31ff9d commit 5f0dec2

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/actions/PageView.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use nullref\cms\models\Page;
66
use Yii;
77
use yii\base\Action;
8+
use yii\caching\TagDependency;
89
use yii\web\NotFoundHttpException;
910

1011

@@ -15,15 +16,15 @@
1516
class PageView extends Action
1617
{
1718
public $view = 'view';
18-
19+
1920
public function run()
2021
{
2122
if (($route = Yii::$app->request->getQueryParam('route')) == null) {
2223
throw new NotFoundHttpException(Yii::t('cms', 'Page not found.'));
2324
}
2425
$page = Page::getDb()->cache(function () use ($route) {
2526
return Page::find()->byRoute($route)->one();
26-
});
27+
}, null, new TagDependency(['tags' => 'cms.page.' . $route]));
2728

2829
if (!isset($page)) {
2930
throw new NotFoundHttpException(Yii::t('cms', 'Page not found.'));
@@ -39,6 +40,8 @@ public function run()
3940
'page' => $page,
4041
]);
4142

43+
//@TODO add tag dependency by blocks
44+
4245
return $result;
4346
}
4447
}

src/controllers/admin/PageController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use nullref\cms\models\Page;
66
use nullref\core\interfaces\IAdminController;
77
use Yii;
8+
use yii\caching\TagDependency;
89
use yii\data\ActiveDataProvider;
910
use yii\filters\VerbFilter;
1011
use yii\web\Controller;
@@ -101,7 +102,8 @@ public function actionUpdate($id)
101102

102103
$default = Yii::$app->request->isPost ? ['PageHasBlock' => []] : [];
103104
if ($model->loadWithRelations(array_merge($default, Yii::$app->request->post())) && $model->save()) {
104-
Yii::$app->cache->delete('cms.page.' . $model->route);
105+
TagDependency::invalidate(Yii::$app->cache, 'cms.page.' . $model->route);
106+
TagDependency::invalidate(Yii::$app->cache, 'cms.page.' . $model->oldAttributes['route']);
105107
return $this->redirect(['view', 'id' => $model->id]);
106108
} else {
107109
return $this->render('update', [

src/views/admin/page/_form.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use mihaildev\ckeditor\CKEditor;
4+
use mihaildev\elfinder\ElFinder;
45
use nullref\cms\assets\PageFormAssets;
56
use nullref\cms\models\Page;
67
use unclead\widgets\MultipleInput;
@@ -55,9 +56,9 @@ class="btn btn-danger btn-xs"
5556
<div class="row" data-type="<?= Page::TYPE_CONTENT ?>" style="display: none">
5657
<div class="col-md-12">
5758
<?= $form->field($model, 'content')->widget(CKEditor::className(), [
58-
'editorOptions' => [
59+
'editorOptions' => ElFinder::ckeditorOptions('elfinder-backend', [
5960
'height' => 300,
60-
]
61+
]),
6162
]) ?>
6263
</div>
6364
</div>

0 commit comments

Comments
 (0)