Files
sterivein/local/modules/PurgeFakeCustomer/Command/FakeCustomerPurge.php

43 lines
1.2 KiB
PHP

<?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 configure()
{
$this
->setName("fakecustomers:purge")
->setDescription("Purge all fake customers")
;
}
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 deleted (Ids : %s)</info>", $event->getDeletedCount(), $event->getDeletedList()));
}
}