public function getFloorsAction() { $elevatorRepository = new ElevatorRepository('data/state'); $floorService = $elevatorRepository->getFloorsService(); $status = $floorService->getFloorsStatus(); return json_encode(["floorsCount" => count($status), "floorsStatus" => $status]); }
public function addRequestAction($request) { $this->elevatorRepository = new ElevatorRepository("data/state"); $this->elevator = $this->elevatorRepository->getElevator(); $this->elevator->addRequest(new ElevatorRequest($request->from, $request->to)); $this->elevatorRepository->saveElevator($this->elevator); return json_encode(["success" => "Request successfully received."]); }
public function sendSignalAction(stdClass $request) { if (!isset($request->signal)) { throw new BadRequestException("Signal not given"); } $elevatorRepository = new ElevatorRepository('data/state'); $elevator = $elevatorRepository->getElevator(); $elevator->sendSignal($request->signal); $elevatorRepository->saveElevator($elevator); return json_encode(["success" => "Signal successfully handled."]); }