4ee91a7918
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KTXC\Console\Firewall;
|
|
|
|
use KTXC\Stores\FirewallStore;
|
|
use Symfony\Component\Console\Attribute\AsCommand;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
|
|
#[AsCommand(name: 'firewall:setup', description: 'Install or verify firewall database indexes')]
|
|
final class FirewallSetupCommand extends Command
|
|
{
|
|
public function __construct(private readonly FirewallStore $store)
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
{
|
|
$io = new SymfonyStyle($input, $output);
|
|
try {
|
|
$indexes = $this->store->ensureIndexes();
|
|
} catch (\Throwable $error) {
|
|
$io->error('Firewall database setup failed: '.$error->getMessage());
|
|
return Command::FAILURE;
|
|
}
|
|
|
|
$io->success(sprintf('Firewall database setup complete. %d indexes verified.', count($indexes)));
|
|
return Command::SUCCESS;
|
|
}
|
|
}
|