Création du module PurgeFakeCustomer

This commit is contained in:
2021-01-12 20:09:20 +01:00
parent f97c314056
commit 4845682d59
5 changed files with 221 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<?php
/**
* Created by Laurent LE CORRE <laurent@thecoredev.fr>
* Date: 12/01/2021
*/
namespace PurgeFakeCustomer\Command;
use PurgeFakeCustomer\Event\FakeCustomerEvent;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Thelia\Command\ContainerAwareCommand;
use Thelia\Model\ConfigQuery;
class FakeCustomerPurge extends ContainerAwareCommand
{
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln(
sprintf("<info>Deleting fake customers</info>")
);
$critere = ConfigQuery::read('purgefakecustomer_critere', '');
$event = new FakeCustomerEvent($critere, $input->getOption('verbose'));
$this->getDispatcher()->dispatch(FakeCustomerEvent::PURGE, $event);
foreach ($event->getStatus() as $status => $level) {
$output->writeln("<$level>$status</$level>");
}
$output->writeln(sprintf("<info>%d fake customers deleteddàçp</info>", $event->getDeletedCount()));
}
}