Remove Assert NotBlank from color and model year. #274

This commit is contained in:
Korina Cordero 2019-11-20 01:40:07 +00:00
parent 9c4db034d0
commit 515bb84c13
2 changed files with 12 additions and 10 deletions

View file

@ -12,6 +12,8 @@ use Doctrine\Common\Persistence\ObjectManager;
use App\Entity\Warranty;
use App\Entity\Customer;
use App\Entity\CustomerVehicle;
use App\Entity\VehicleManufacturer;
use App\Entity\Vehicle;
class CreateCustomerFromWarrantyCommand extends Command
{
@ -56,6 +58,8 @@ class CreateCustomerFromWarrantyCommand extends Command
{
$w_mobile_array = preg_split('/[\/\\]/', $w_mobile);
}
else
{
// only one mobile number
$w_mobile_array[] = $w_mobile;
}
@ -66,7 +70,11 @@ class CreateCustomerFromWarrantyCommand extends Command
$w_plate_number = $warr->getPlateNumber();
$default_cv_color = 'White';
// TODO: add checking that default manufacturer is not null
$default_manufacturer = $this->em->getRepository(VehicleManufacturer::class)->findBy('name' =>'Unknown');
$default_manufacturer = $this->em->getRepository(VehicleManufacturer::class)->findBy(['name' =>'Unknown']);
if (empty($default_manufacturer))
{
$output->writeln("Need to add manufacturer with Unknown name");
}
$default_make = 'Unknown';
// search cust_index for numbers in mobile_array
foreach ($w_mobile_array as $w_mobile_num)
@ -82,7 +90,7 @@ class CreateCustomerFromWarrantyCommand extends Command
// mobile number belongs to existing customer
// get customer vehicles
$c_vehicles = $customer->getVehicles();
if (!(empty($c_vehicles))
if (!(empty($c_vehicles)))
{
// check if plate number of customer vehicle matches warranty plate number
foreach ($c_vehicles as $c_vehicle)
@ -90,7 +98,7 @@ class CreateCustomerFromWarrantyCommand extends Command
$cv_plate_number = $c_vehicle->getPlateNumber();
if ($cv_plate_number == $w_plate_number)
{
// get out of all loops since current warranty belongs to an
// move to the next warranty since current warranty belongs to an
// existing customer and customer vehicle
break 3;
}
@ -118,13 +126,11 @@ class CreateCustomerFromWarrantyCommand extends Command
$this->em->persist($cust);
$this->createCustomerVehicle($cust, $default_manufacturer,
$default_make, $w_plate_number, $default_cv_color)
$default_make, $w_plate_number, $default_cv_color);
}
}
}
}
protected function loadCustomers()
@ -143,11 +149,9 @@ class CreateCustomerFromWarrantyCommand extends Command
protected function createCustomerVehicle(Customer $cust, $manufacturer, $make,
$plate_number, $color)
{
$new_vehicle = new Vehicle();
$new_cv = new CustomerVehicle();
// get manufacturer and make with name 'unknown'
$new_vehicle->setManufacturer($manufacturer)
// TODO: remove the assert not blank for color and model year
$new_cv->setCustomer($cust)

View file

@ -54,14 +54,12 @@ class CustomerVehicle
// model year
/**
* @ORM\Column(type="smallint")
* @Assert\NotBlank()
*/
protected $model_year;
// color of customer's vehicle
/**
* @ORM\Column(type="string", length=80)
* @Assert\NotBlank()
*/
protected $color;