setOrderWarehouse = new SetsOrderWarehouse(); $this->generateOrderSteps = new GenerateOrderSteps(); } /** * @param OrderObject $order * @param StepObject $step * @param int $warehouseId * @return JsonResponse * @throws InternalServerErrorException */ public function execute(OrderObject $order, StepObject $step, ?int $warehouseId = null){ try { if($warehouseId){ $order->setWarehouseId($warehouseId); $this->setOrderWarehouse->execute($order); } $this->generateOrderSteps->execute($order); $this->completeStep($order, $step); return new JsonResponse(null, HttpStatus::RESOURCE_CREATED); } catch (\Exception $exception){ throw new InternalServerErrorException("Failed to update order step because {$exception->getMessage()}"); } } }