update with latest changes and DE translations
This commit is contained in:
35
formwidgets/ClearCacheButton.php
Normal file
35
formwidgets/ClearCacheButton.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php namespace NicoSt\GCalendar\FormWidgets;
|
||||
|
||||
use Backend\Classes\FormWidgetBase;
|
||||
use Cache;
|
||||
use Log;
|
||||
use Flash;
|
||||
use Lang;
|
||||
|
||||
use NicoSt\GCalendar\Models\Settings;
|
||||
|
||||
class ClearCacheButton extends FormWidgetBase {
|
||||
|
||||
protected $defaultAlias = 'clearCacheButton';
|
||||
|
||||
private $cacheKeyCalendarList = 'GCalendar-CalendarList';
|
||||
private $cacheKeyCalendarGet = 'GCalendar-CalendarGet#';
|
||||
|
||||
public function render() {
|
||||
return $this->makePartial('clearCacheButton');
|
||||
}
|
||||
|
||||
// Clear cache for all saved calendars
|
||||
public function onClearCache() {
|
||||
$calendarSelectors = Settings::get('calendar_selector', []);
|
||||
|
||||
foreach ($calendarSelectors as &$selector) {
|
||||
Cache::forget($this->cacheKeyCalendarGet.$selector['id']);
|
||||
}
|
||||
Cache::forget($this->cacheKeyCalendarList);
|
||||
|
||||
Log::info('G-Calendar: Cache cleared!');
|
||||
Flash::success(Lang::get('nicost.gcalendar::lang.widget.clearCacheButton.success'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class OAuth extends FormWidgetBase {
|
||||
|
||||
$this->vars['auth_url'] = $authUrl;
|
||||
|
||||
return $this->makePartial('gaccess');
|
||||
return $this->makePartial('gaccess');
|
||||
}
|
||||
|
||||
Log::info('G-Calendar: Access token not expired.');
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<button type="button"
|
||||
data-request="onClearCache"
|
||||
class="btn btn-default">
|
||||
<?= e(trans('nicost.gcalendar::lang.widget.clearCacheButton.buttonText')) ?>
|
||||
</button>
|
||||
Reference in New Issue
Block a user