/** * AlreadyCreatedOperationException constructor. * * @param OperationInterface $operation * @param string $message * @param int $code * @param Exception $previous */ public function __construct($operation, $message = '', $code = 0, Exception $previous = null) { $this->operation = $operation; $miraklId = $operation->getMiraklId() ?: 'operateur'; parent::__construct($message ?: "An operation for {$miraklId} is already\n created for the payment voucher {$operation->getPaymentVoucher()}", $code, $previous); }
/** * Validate an operation * * @param OperationInterface $operation * * @return bool */ public function isOperationValid(OperationInterface $operation) { try { if ($this->operationManager->findByMiraklIdAndPaymentVoucherNumber($operation->getMiraklId(), $operation->getPaymentVoucher())) { throw new AlreadyCreatedOperationException($operation); } if (!$this->operationManager->isValid($operation)) { throw new InvalidOperationException($operation); } ModelValidator::validate($operation); } catch (Exception $e) { $this->handleException($e); return false; } return true; }