Fix syntax errors. #274
This commit is contained in:
parent
515bb84c13
commit
6bde277fef
1 changed files with 16 additions and 22 deletions
|
|
@ -15,6 +15,9 @@ use App\Entity\CustomerVehicle;
|
||||||
use App\Entity\VehicleManufacturer;
|
use App\Entity\VehicleManufacturer;
|
||||||
use App\Entity\Vehicle;
|
use App\Entity\Vehicle;
|
||||||
|
|
||||||
|
use App\Ramcar\FuelType;
|
||||||
|
use App\Ramcar\VehicleStatusCondition;
|
||||||
|
|
||||||
class CreateCustomerFromWarrantyCommand extends Command
|
class CreateCustomerFromWarrantyCommand extends Command
|
||||||
{
|
{
|
||||||
protected $em;
|
protected $em;
|
||||||
|
|
@ -24,8 +27,6 @@ class CreateCustomerFromWarrantyCommand extends Command
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
|
|
||||||
$this->loadCustomers();
|
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -35,9 +36,10 @@ class CreateCustomerFromWarrantyCommand extends Command
|
||||||
->setDescription('Create customers from existing warranties.')
|
->setDescription('Create customers from existing warranties.')
|
||||||
->setHelp('Creates customers from existing warranties.');
|
->setHelp('Creates customers from existing warranties.');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
// load all customers
|
||||||
|
$this->loadCustomers();
|
||||||
// get all warranties
|
// get all warranties
|
||||||
$warranties = $this->em->getRepository(Warranty::class)->findAll();
|
$warranties = $this->em->getRepository(Warranty::class)->findAll();
|
||||||
|
|
||||||
|
|
@ -68,14 +70,11 @@ class CreateCustomerFromWarrantyCommand extends Command
|
||||||
|
|
||||||
// set values for new customer vehicle
|
// set values for new customer vehicle
|
||||||
$w_plate_number = $warr->getPlateNumber();
|
$w_plate_number = $warr->getPlateNumber();
|
||||||
$default_cv_color = 'White';
|
$default_vehicle = $this->em->getRepository(Vehicle::class)->findBy(['name' =>'Unknown']);
|
||||||
// TODO: add checking that default manufacturer is not null
|
if (empty($default_vehicle))
|
||||||
$default_manufacturer = $this->em->getRepository(VehicleManufacturer::class)->findBy(['name' =>'Unknown']);
|
|
||||||
if (empty($default_manufacturer))
|
|
||||||
{
|
{
|
||||||
$output->writeln("Need to add manufacturer with Unknown name");
|
$output->writeln("Need to add vehicle with manufacturer name Unknown and make name Unknown");
|
||||||
}
|
}
|
||||||
$default_make = 'Unknown';
|
|
||||||
// search cust_index for numbers in mobile_array
|
// search cust_index for numbers in mobile_array
|
||||||
foreach ($w_mobile_array as $w_mobile_num)
|
foreach ($w_mobile_array as $w_mobile_num)
|
||||||
{
|
{
|
||||||
|
|
@ -105,8 +104,7 @@ class CreateCustomerFromWarrantyCommand extends Command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add customer vehicle to existing customer with unknown manufacturer and make
|
// add customer vehicle to existing customer with unknown manufacturer and make
|
||||||
$this->createCustomerVehicle($customer, $default_manufacturer,
|
$this->createCustomerVehicle($customer, $default_vehicle, $w_plate_number);
|
||||||
$default_make, $w_plate_number, $default_cv_color);
|
|
||||||
}
|
}
|
||||||
$cust_found = true;
|
$cust_found = true;
|
||||||
}
|
}
|
||||||
|
|
@ -125,8 +123,7 @@ class CreateCustomerFromWarrantyCommand extends Command
|
||||||
|
|
||||||
$this->em->persist($cust);
|
$this->em->persist($cust);
|
||||||
|
|
||||||
$this->createCustomerVehicle($cust, $default_manufacturer,
|
$this->createCustomerVehicle($cust, $default_vehicle, $w_plate_number);
|
||||||
$default_make, $w_plate_number, $default_cv_color);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -146,20 +143,17 @@ class CreateCustomerFromWarrantyCommand extends Command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createCustomerVehicle(Customer $cust, $manufacturer, $make,
|
protected function createCustomerVehicle(Customer $cust, $vehicle, $plate_number)
|
||||||
$plate_number, $color)
|
|
||||||
{
|
{
|
||||||
$new_cv = new CustomerVehicle();
|
$new_cv = new CustomerVehicle();
|
||||||
|
|
||||||
// get manufacturer and make with name 'unknown'
|
|
||||||
|
|
||||||
// TODO: remove the assert not blank for color and model year
|
|
||||||
$new_cv->setCustomer($cust)
|
$new_cv->setCustomer($cust)
|
||||||
->setPlateNumber($plate_number)
|
->setPlateNumber($plate_number)
|
||||||
->setModelYear(0)
|
|
||||||
->setColor($color)
|
|
||||||
->setStatusCondition(VehicleStatusCondition::BRAND_NEW)
|
->setStatusCondition(VehicleStatusCondition::BRAND_NEW)
|
||||||
->setFuelType(FuelType::GAS)
|
->setFuelType(FuelType::GAS)
|
||||||
->setVehicle($vehicle);
|
->setVehicle($vehicle);
|
||||||
|
|
||||||
|
$this->em->persist($new_cv);
|
||||||
|
$this->em->flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue