handle unset order in order based document types

This commit is contained in:
2023-09-19 23:32:55 +02:00
parent 93fd76de19
commit 1e91990a28
13 changed files with 61 additions and 55 deletions

View File

@ -10,9 +10,10 @@
namespace D3\PdfDocuments\Application\Model\AbstractClasses;
use D3\PdfDocuments\Application\Model\Exceptions\noBaseObjectSetException;
use Assert\Assert;
use Assert\InvalidArgumentException;
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface as orderInterface;
use \OxidEsales\Eshop\Application\Model\Order;
use OxidEsales\Eshop\Application\Model\Order;
use OxidEsales\Eshop\Application\Model\Payment;
use OxidEsales\Eshop\Application\Model\User;
use OxidEsales\Eshop\Core\Registry;
@ -22,6 +23,14 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
/** @var Order */
public $oOrder;
/**
* don't use order as constructor argument because of same method interface for all document types
*/
public function __construct()
{
parent::__construct();
}
/**
* @param Order $order
*/
@ -31,15 +40,22 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
}
/**
* @throws InvalidArgumentException
* @return Order
*/
public function getOrder()
{
Assert::lazy()
->that($this->oOrder)->isInstanceOf(Order::class, 'no order for pdf generator set')
->that($this->oOrder->isLoaded())->true('given order is not loaded')
->verifyNow();
return $this->oOrder;
}
/**
* @param int $iSelLang
* @throws InvalidArgumentException
*/
public function setSmartyVars($iSelLang)
{
@ -58,6 +74,7 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
/**
* @return string
* @throws InvalidArgumentException
*/
public function getFilename()
{
@ -86,21 +103,6 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
);
}
/**
* @param $sFilename
* @param int $iSelLang
* @param string $target
* @return mixed|string|null
*/
public function genPdf($sFilename, $iSelLang = 0, $target = 'I')
{
if (false == $this->getOrder()) {
throw oxNew(noBaseObjectSetException::class);
}
return parent::genPdf($sFilename, $iSelLang, $target);
}
/**
* @return int
*/
@ -115,6 +117,7 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
/**
* @return false|string
* @throws InvalidArgumentException
*/
public function getPayableUntilDate()
{