caseManagement = $caseManagement; $this->caseUpdatingServiceFactory = $caseUpdatingServiceFactory; $this->gateway = $gateway; $this->createGuaranteeAbility = $createGuaranteeAbility; $this->logger = $logger; } /** * @inheritdoc */ public function createForOrder($orderId) { if (!$this->createGuaranteeAbility->isAvailable($orderId)) { return false; } $caseEntity = $this->caseManagement->getByOrderId($orderId); try { $disposition = $this->gateway->submitCaseForGuarantee($caseEntity->getCaseId()); } catch (GatewayException $e) { $this->logger->error($e->getMessage()); return false; } $updatingService = $this->caseUpdatingServiceFactory->create('guarantees/creation'); $data = [ 'caseId' => $caseEntity->getCaseId(), 'guaranteeDisposition' => $disposition ]; $updatingService->update($caseEntity, $data); return true; } }