From 083523bcc34cedafc92174451b2fc25abb0291b6 Mon Sep 17 00:00:00 2001 From: Elias Luhr Date: Wed, 10 Jun 2020 08:19:04 +0200 Subject: [PATCH] moved cache flush functionality into separate controller --- src/controllers/CacheController.php | 35 +++++++++++++++++++++++++++ src/controllers/DefaultController.php | 18 -------------- src/views/default/index.php | 2 +- 3 files changed, 36 insertions(+), 19 deletions(-) create mode 100644 src/controllers/CacheController.php diff --git a/src/controllers/CacheController.php b/src/controllers/CacheController.php new file mode 100644 index 0000000..6e9224b --- /dev/null +++ b/src/controllers/CacheController.php @@ -0,0 +1,35 @@ +cache->flush()) { + \Yii::$app->session->addFlash('success', Yii::t('backend-module','Cache cleared')); + } else { + \Yii::$app->session->addFlash('error', Yii::t('backend-module','Cannot clear cache')); + } + return $this->redirect(['default/index']); + } +} \ No newline at end of file diff --git a/src/controllers/DefaultController.php b/src/controllers/DefaultController.php index 97102d9..5a94263 100644 --- a/src/controllers/DefaultController.php +++ b/src/controllers/DefaultController.php @@ -75,22 +75,4 @@ public function renderDashboardMenu($item = []) return $menuItems; } - /** - * flush cache - * - * if APCu is used as cache we cannot flush cache from cli command - * see: https://github.com/yiisoft/yii2/issues/8647 - * - * @return \yii\web\Response - */ - public function actionCacheFlush() - { - if (Yii::$app->cache->flush()) { - Yii::$app->session->addFlash('success', Yii::t('backend-module','Cache cleared')); - } else { - Yii::$app->session->addFlash('error', Yii::t('backend-module','Cannot clear cache')); - } - return $this->goBack(['index']); - } - } diff --git a/src/views/default/index.php b/src/views/default/index.php index 90b40ec..69ee379 100644 --- a/src/views/default/index.php +++ b/src/views/default/index.php @@ -164,7 +164,7 @@
- +