/**
  * @param VehicleCategory $vehicleCategory
  * @return VehicleCategoryListDTO
  */
 public function toVehicleCategoryListDTO(VehicleCategory $vehicleCategory)
 {
     $vehicleCategoryListDTO = new VehicleCategoryListDTO();
     $vehicleCategoryListDTO->id = $vehicleCategory->getId();
     $vehicleCategoryListDTO->name = $vehicleCategory->getName();
     $vehicleCategoryListDTO->amountOfSeats = $vehicleCategory->getAmountOfSeats();
     $vehicleCategoryListDTO->amountOfWheelChairs = $vehicleCategory->getAmountOfWheelChairs();
     return $vehicleCategoryListDTO;
 }
예제 #2
0
 /**
  * @param $name
  * @param $seats
  * @param $wheelchairs
  * @return null|object|VehicleCategory
  */
 private function createVehicleCategory($name, $seats, $wheelchairs)
 {
     $vehicleCat = $this->init->vehicleCategoryRepo->findOneBy(array('name' => $name));
     if (empty($vehicleCat)) {
         $vehicleCat = VehicleCategory::registerVehicleCategory($name, $seats, $wheelchairs);
         $this->init->vehicleCategoryRepo->store($vehicleCat);
     }
     return $vehicleCat;
 }
예제 #3
0
 /**
  * @param $name
  * @param $amountOfSeats
  * @param null $amountOfWheelChairs
  * @param integer $sortOrder
  * @param null $memo
  * @return VehicleCategory
  */
 public static function registerVehicleCategory($name, $amountOfSeats, $amountOfWheelChairs = null, $sortOrder = 0, $memo = null)
 {
     $vehicleCategory = new VehicleCategory();
     $vehicleCategory->setName($name);
     $vehicleCategory->setMemo($memo);
     $vehicleCategory->setAmountOfSeats($amountOfSeats);
     $amountOfWheelChairs = null !== $amountOfWheelChairs ? $amountOfWheelChairs : 0;
     $vehicleCategory->setAmountOfWheelChairs($amountOfWheelChairs);
     $vehicleCategory->setSortOrder($sortOrder);
     return $vehicleCategory;
 }
예제 #4
0
 private function driverSuperviseVehicle(Driver $driver)
 {
     $vehicleCategory = VehicleCategory::registerVehicleCategory('Movano Maxi', 4, 2);
     $this->init->vehicleCategoryRepo->store($vehicleCategory);
     $vehicle = Vehicle::registerVehicle('Movano 1', 'CH123', new \DateTime('2012-11-11'), 1, $vehicleCategory);
     $this->init->vehicleRepo->store($vehicle);
     $driver->assignSupervisedVehicle($vehicle);
     $this->init->driverRepo->store($driver);
     $this->init->em->flush();
     /**@var Driver $driverFound */
     $driverFound = $this->init->driverRepo->find($driver->getId());
     $supervisedVehicles = $driverFound->getSupervisedVehicles();
     $found = true;
     foreach ($supervisedVehicles as $s) {
         if ($s->getId() == $vehicle->getId()) {
             $found = true;
         }
     }
     $this->assertTrue($found);
 }
예제 #5
0
 /**
  * drives certain vehicle categories
  * @param VehicleCategory $vehicleCategory
  * @return bool
  */
 public function isCompatibleWithVehicleCategory(VehicleCategory $vehicleCategory)
 {
     /**@var $contradict VehicleCategory */
     foreach ($this->contradictVehicleCategories as $contradict) {
         if ($vehicleCategory->getId() === $contradict->getId()) {
             return false;
         }
     }
     return true;
 }
예제 #6
0
 /**
  * @param VehicleCategory $vehicleCategory
  * @return bool
  */
 public function isCompatibleWithVehicleCategory(VehicleCategory $vehicleCategory)
 {
     if ($this->isInWheelChair) {
         if ($vehicleCategory->getAmountOfWheelChairs() < 1) {
             return false;
         }
     }
     /**@var $contradict VehicleCategory */
     foreach ($this->contradictVehicleCategories as $contradict) {
         if ($vehicleCategory->getId() === $contradict->getId()) {
             return false;
         }
     }
     return true;
 }