54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Command;
|
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
use App\Entity\Customer;
|
|
|
|
class UpdateCMBMigratedCustomerCommand extends Command
|
|
{
|
|
// last name to set
|
|
const STR_LAST_NAME = 'LEGACY';
|
|
|
|
protected $em;
|
|
|
|
public function __construct(EntityManagerInterface $em)
|
|
{
|
|
$this->em = $em;
|
|
|
|
parent::__construct();
|
|
}
|
|
|
|
protected function configure()
|
|
{
|
|
$this->setName('cmbcustomer:updatecustomer')
|
|
->setDescription('Set customer last name.')
|
|
->setHelp('Set the customer last name. ');
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
error_log('Updating customer last name...');
|
|
|
|
// get all customers
|
|
$cust_results = $this->em->getRepository(Customer::class)->findBy(['last_name' => '']);
|
|
|
|
foreach ($cust_results as $cust)
|
|
{
|
|
$cust->setLastName(self::STR_LAST_NAME);
|
|
}
|
|
|
|
$this->em->flush();
|
|
$this->em->clear();
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
}
|