feat: UI/UX, add reset cache to admin
This commit is contained in:
@@ -6,6 +6,7 @@ use Bastion\Exceptions\BotTokenConfiguratorException;
|
||||
use Bastion\Services\BotTokenConfigurator;
|
||||
use Bastion\Services\SettingsService;
|
||||
use Exception;
|
||||
use Openguru\OpenCartFramework\Cache\CacheInterface;
|
||||
use Openguru\OpenCartFramework\Config\Settings;
|
||||
use Openguru\OpenCartFramework\Http\JsonResponse;
|
||||
use Openguru\OpenCartFramework\Http\Request;
|
||||
@@ -17,15 +18,18 @@ class SettingsHandler
|
||||
private BotTokenConfigurator $botTokenConfigurator;
|
||||
private Settings $settings;
|
||||
private SettingsService $settingsUpdateService;
|
||||
private CacheInterface $cache;
|
||||
|
||||
public function __construct(
|
||||
BotTokenConfigurator $botTokenConfigurator,
|
||||
Settings $settings,
|
||||
SettingsService $settingsUpdateService
|
||||
SettingsService $settingsUpdateService,
|
||||
CacheInterface $cache
|
||||
) {
|
||||
$this->botTokenConfigurator = $botTokenConfigurator;
|
||||
$this->settings = $settings;
|
||||
$this->settingsUpdateService = $settingsUpdateService;
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
public function configureBotToken(Request $request): JsonResponse
|
||||
@@ -71,4 +75,11 @@ class SettingsHandler
|
||||
private function validate(array $input): void
|
||||
{
|
||||
}
|
||||
|
||||
public function resetCache(): JsonResponse
|
||||
{
|
||||
$this->cache->prune();
|
||||
|
||||
return new JsonResponse([], Response::HTTP_ACCEPTED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,4 +21,5 @@ return [
|
||||
|
||||
'getAutocompleteCategories' => [AutocompleteHandler::class, 'getCategories'],
|
||||
'getAutocompleteCategoriesFlat' => [AutocompleteHandler::class, 'getCategoriesFlat'],
|
||||
'resetCache' => [SettingsHandler::class, 'resetCache'],
|
||||
];
|
||||
|
||||
@@ -11,4 +11,6 @@ interface CacheInterface
|
||||
public function delete(string $key): void;
|
||||
|
||||
public function clear(): void;
|
||||
|
||||
public function prune(): void;
|
||||
}
|
||||
|
||||
@@ -41,4 +41,9 @@ class SymfonyMySqlCache implements CacheInterface
|
||||
{
|
||||
$this->cache->clear();
|
||||
}
|
||||
|
||||
public function prune(): void
|
||||
{
|
||||
$this->cache->prune();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user