Files
emails/cli/common/Command/Messages/Grab.php

42 lines
1.2 KiB
PHP
Raw Normal View History

2022-11-25 20:52:46 -03:00
<?php
2023-06-09 00:54:34 -04:00
namespace ProVM\Command\Messages;
2022-11-25 20:52:46 -03:00
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
2023-06-09 00:54:34 -04:00
use Symfony\Component\Console\Input\InputArgument;
2022-11-25 20:52:46 -03:00
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
2023-06-12 21:14:07 -04:00
use ProVM\Service\Mailboxes;
2022-11-25 20:52:46 -03:00
#[AsCommand(
name: 'messages:grab',
2023-06-12 21:14:07 -04:00
description: 'Run grab messages job for mailbox',
2022-11-25 20:52:46 -03:00
hidden: false
)]
2023-06-09 00:54:34 -04:00
class Grab extends Command
2022-11-25 20:52:46 -03:00
{
2023-06-12 21:14:07 -04:00
public function __construct(protected Mailboxes $service, string $name = null)
2022-11-25 20:52:46 -03:00
{
parent::__construct($name);
}
2023-06-09 00:54:34 -04:00
protected function configure()
{
$this->addArgument('mailbox_id', InputArgument::REQUIRED, 'Mailbox ID to grab emails');
}
2022-11-25 20:52:46 -03:00
public function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
2023-06-09 00:54:34 -04:00
$mailbox_id = $input->getArgument('mailbox_id');
$io->title("Grabbing Messages for Mailbox ID {$mailbox_id}");
2022-11-25 20:52:46 -03:00
$io->section('Grabbing Messages');
2023-06-12 21:14:07 -04:00
$count = $this->service->grabMessages($mailbox_id);
2023-06-09 00:54:34 -04:00
$io->info("Found {$count} messages");
2022-11-25 20:52:46 -03:00
$io->success('Done.');
return Command::SUCCESS;
}
2023-06-08 20:49:27 -04:00
}