/** * @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; }
/** * @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; }
/** * @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; }
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); }
/** * 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; }
/** * @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; }