Commit 301b0251 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Correction pour afficher les barres de progression des TBL comme contrat

parent 6608d305
Loading
Loading
Loading
Loading
Loading
+19 −2
Changes for module/Administration/src/Command/CalculTableauxBordCommand.php: 19 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Administration\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
@@ -18,6 +19,8 @@ class CalculTableauxBordCommand extends Command
{
    use TableauBordServiceAwareTrait;

    private ProgressBar $progressBar;

    protected function configure(): void
    {
        $this->setDescription('Calcul des tableaux de bord');
@@ -29,6 +32,8 @@ class CalculTableauxBordCommand extends Command

        $io->title($this->getDescription());

        $this->progressBar = $io->createProgressBar(0);

        $this->getServiceTableauBord()->setOnAction(function(Event $event) use ($io){
            $this->onEvent($event, $io);
        });
@@ -56,8 +61,20 @@ class CalculTableauxBordCommand extends Command
            case Event::FINISH:
                $io->info("Calcul effectué en ".round($event->tableauBord->getTiming(), 3)." secondes");
                break;
            default:
                echo $event->action."\n";
            case Event::GET:
                $io->info("Récupération des données");
                break;
            case Event::PROCESS:
                $io->info("Traitement");
                $this->progressBar = $io->createProgressBar($event->total);
                break;
            case Event::SET:
                $io->info("Enregistrement");
                $this->progressBar = $io->createProgressBar($event->total);
                break;
            case Event::PROGRESS:
                $this->progressBar->setMaxSteps($event->total);
                $this->progressBar->setProgress($event->progress);
        }
    }