42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
namespace ProVM\Command\Messages;
|
|
|
|
use Symfony\Component\Console\Attribute\AsCommand;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
use ProVM\Service\Mailboxes;
|
|
|
|
#[AsCommand(
|
|
name: 'messages:grab',
|
|
description: 'Run grab messages job for mailbox',
|
|
hidden: false
|
|
)]
|
|
class Grab extends Command
|
|
{
|
|
public function __construct(protected Mailboxes $service, string $name = null)
|
|
{
|
|
parent::__construct($name);
|
|
}
|
|
protected function configure()
|
|
{
|
|
$this->addArgument('mailbox_id', InputArgument::REQUIRED, 'Mailbox ID to grab emails');
|
|
}
|
|
|
|
public function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
$io = new SymfonyStyle($input, $output);
|
|
|
|
$mailbox_id = $input->getArgument('mailbox_id');
|
|
$io->title("Grabbing Messages for Mailbox ID {$mailbox_id}");
|
|
$io->section('Grabbing Messages');
|
|
$count = $this->service->grabMessages($mailbox_id);
|
|
$io->info("Found {$count} messages");
|
|
$io->success('Done.');
|
|
|
|
return Command::SUCCESS;
|
|
}
|
|
}
|