mirror of
https://github.com/slawkens/myaac.git
synced 2025-11-03 17:26:23 +01:00
settings:set + settings:reset commands
This commit is contained in:
36
system/src/Commands/SettingsResetCommand.php
Normal file
36
system/src/Commands/SettingsResetCommand.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace MyAAC\Commands;
|
||||
|
||||
use MyAAC\Models\Settings as SettingsModel;
|
||||
use MyAAC\Settings;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
class SettingsResetCommand extends Command
|
||||
{
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->setName('settings:reset')
|
||||
->setDescription('Removes all settings in database');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
if (!$io->confirm('Are you sure you want to reset all settings in database?', false)) {
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
SettingsModel::truncate();
|
||||
|
||||
$settings = Settings::getInstance();
|
||||
$settings->clearCache();
|
||||
|
||||
$io->success('Setting cleared successfully');
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user