mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-05 14:53:12 +08:00
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Shlinkio\Shlink\CLI\Command\Visit;
|
|
|
|
use Shlinkio\Shlink\CLI\Util\ExitCode;
|
|
use Shlinkio\Shlink\Core\Visit\VisitsDeleterInterface;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
|
|
use function sprintf;
|
|
|
|
class DeleteOrphanVisitsCommand extends AbstractDeleteVisitsCommand
|
|
{
|
|
public const NAME = 'visit:orphan-delete';
|
|
|
|
public function __construct(private readonly VisitsDeleterInterface $deleter)
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
protected function configure(): void
|
|
{
|
|
$this
|
|
->setName(self::NAME)
|
|
->setDescription('Deletes all orphan visits');
|
|
}
|
|
|
|
protected function doExecute(InputInterface $input, SymfonyStyle $io): int
|
|
{
|
|
$result = $this->deleter->deleteOrphanVisits();
|
|
$io->success(sprintf('Successfully deleted %s visits', $result->affectedItems));
|
|
|
|
return ExitCode::EXIT_SUCCESS;
|
|
}
|
|
|
|
protected function getWarningMessage(): string
|
|
{
|
|
return 'You are about to delete all orphan visits. This operation cannot be undone.';
|
|
}
|
|
}
|