mirror of
https://github.com/code-rhapsodie/dataflow-bundle.git
synced 2026-04-28 16:43:10 +02:00
4e82b114c4
* Add auto update count processed item while running job
57 lines
2.0 KiB
PHP
57 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace CodeRhapsodie\DataflowBundle\Command;
|
|
|
|
use CodeRhapsodie\DataflowBundle\Factory\ConnectionFactory;
|
|
use CodeRhapsodie\DataflowBundle\Repository\ScheduledDataflowRepository;
|
|
use Symfony\Component\Console\Attribute\AsCommand;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
|
|
/**
|
|
* @codeCoverageIgnore
|
|
*/
|
|
#[AsCommand('code-rhapsodie:dataflow:schedule:list', 'List scheduled dataflows')]
|
|
class ScheduleListCommand extends Command
|
|
{
|
|
public function __construct(private ScheduledDataflowRepository $scheduledDataflowRepository, private ConnectionFactory $connectionFactory)
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
protected function configure(): void
|
|
{
|
|
$this
|
|
->setHelp('The <info>%command.name%</info> lists all scheduled dataflows.')
|
|
->addOption('connection', null, InputOption::VALUE_REQUIRED, 'Define the DBAL connection to use');
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
{
|
|
if ($input->getOption('connection') !== null) {
|
|
$this->connectionFactory->setConnectionName($input->getOption('connection'));
|
|
}
|
|
$io = new SymfonyStyle($input, $output);
|
|
$display = [];
|
|
$schedules = $this->scheduledDataflowRepository->listAllOrderedByLabel();
|
|
foreach ($schedules as $schedule) {
|
|
$display[] = [
|
|
$schedule['id'],
|
|
$schedule['label'],
|
|
$schedule['enabled'] ? 'yes' : 'no',
|
|
$schedule['startTime'] ? (new \DateTime($schedule['startTime']))->format('Y-m-d H:i:s') : '-',
|
|
$schedule['next'] ? (new \DateTime($schedule['next']))->format('Y-m-d H:i:s') : '-',
|
|
];
|
|
}
|
|
|
|
$io->table(['id', 'label', 'enabled?', 'last execution', 'next execution'], $display);
|
|
|
|
return 0;
|
|
}
|
|
}
|