getContainer()->getPermissionsService()->currentUserCanWrite(Entities::FINANCE)) { throw new AccessDeniedException('You are not allowed to update payment.'); } $result = new CommandResult(); $this->checkMandatoryFields($command); $payment = PaymentFactory::create($command->getFields()); if (!$payment instanceof Payment) { $result->setResult(CommandResult::RESULT_ERROR); $result->setMessage('Unable to update payment.'); return $result; } /** @var PaymentRepository $paymentRepository */ $paymentRepository = $this->container->get('domain.payment.repository'); if ($paymentRepository->update($command->getArg('id'), $payment)) { $result->setResult(CommandResult::RESULT_SUCCESS); $result->setMessage('Payment successfully updated.'); $result->setData( [ Entities::PAYMENT => $payment->toArray(), ] ); } return $result; } }