Skip to content

Commit 00c3301

Browse files
committed
add cleanup command
1 parent 0d51777 commit 00c3301

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/Command/CleanupCommand.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Frosh\MailArchive\Command;
6+
7+
use Frosh\MailArchive\Messenger\CleanupMessage;
8+
use Symfony\Component\Console\Attribute\AsCommand;
9+
use Symfony\Component\Console\Command\Command;
10+
use Symfony\Component\Console\Input\InputInterface;
11+
use Symfony\Component\Console\Output\OutputInterface;
12+
use Symfony\Component\Messenger\MessageBusInterface;
13+
14+
#[AsCommand('frosh:mail-archive:cleanup', 'Cleanup old mail archive entries')]
15+
class CleanupCommand extends Command
16+
{
17+
public function __construct(
18+
private readonly MessageBusInterface $messageBus,
19+
20+
) {
21+
parent::__construct();
22+
}
23+
24+
protected function execute(InputInterface $input, OutputInterface $output): int
25+
{
26+
$output->writeln('Dispatching mail archive cleanup...');
27+
28+
$this->messageBus->dispatch(new CleanupMessage());
29+
30+
$output->writeln('Cleanup message dispatched successfully.');
31+
32+
return Command::SUCCESS;
33+
}
34+
}

0 commit comments

Comments
 (0)