mirror of
https://github.com/humhub/humhub.git
synced 2025-01-18 22:58:06 +01:00
Enh: Flush also assets directory on cache delete
This commit is contained in:
parent
0a4a91cb5a
commit
23147e3b62
39
protected/humhub/components/AssetManager.php
Normal file
39
protected/humhub/components/AssetManager.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2016 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\components;
|
||||
|
||||
use yii\helpers\FileHelper;
|
||||
|
||||
/**
|
||||
* AssetManager
|
||||
*
|
||||
* @inheritdoc
|
||||
* @author Luke
|
||||
*/
|
||||
class AssetManager extends \yii\web\AssetManager
|
||||
{
|
||||
|
||||
/**
|
||||
* Clears all currently published assets
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
if ($this->basePath == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (scandir($this->basePath) as $file) {
|
||||
if (substr($file, 0, 1) === '.') {
|
||||
continue;
|
||||
}
|
||||
FileHelper::removeDirectory($this->basePath . DIRECTORY_SEPARATOR . $file);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -84,6 +84,7 @@ $config = [
|
||||
],
|
||||
],
|
||||
'assetManager' => [
|
||||
'class' => '\humhub\components\AssetManager',
|
||||
'appendTimestamp' => true,
|
||||
],
|
||||
'view' => [
|
||||
|
@ -149,7 +149,7 @@ class SettingController extends Controller
|
||||
$form = new \humhub\modules\admin\models\forms\CacheSettingsForm;
|
||||
if ($form->load(Yii::$app->request->post()) && $form->validate() && $form->save()) {
|
||||
Yii::$app->cache->flush();
|
||||
|
||||
Yii::$app->assetManager->clear();
|
||||
Yii::$app->getSession()->setFlash('data-saved', Yii::t('AdminModule.controllers_SettingController', 'Saved and flushed cache'));
|
||||
return $this->redirect(['/admin/setting/caching']);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user