35 lines
972 B
PHP
Executable File
35 lines
972 B
PHP
Executable File
<?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'));
|
|
}
|
|
|
|
} |