throw exception in case of undefined pdf request type

This commit is contained in:
Daniel Seifert 2020-05-29 09:58:53 +02:00
parent 7a59380d43
commit fcb4a364d0
2 changed files with 35 additions and 6 deletions

View File

@ -17,6 +17,7 @@ namespace D3\PdfDocuments\Application\Controller;
use D3\PdfDocuments\Application\Model\Documents\deliverynotePdf;
use D3\PdfDocuments\Application\Model\Documents\invoicePdf;
use D3\PdfDocuments\Application\Model\Exceptions\d3noPdfHandlerFoundException;
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocuments_order_interface as OrderPdfInterface;
use OxidEsales\Eshop\Application\Model\Order;
use OxidEsales\Eshop\Core\Registry;
@ -60,16 +61,17 @@ echo __CLASS__." - ".__FUNCTION__." - ".__LINE__."<br>";
}
/**
* @param Order $order
*
* @return OrderPdfInterface
* @throws \OxidEsales\Eshop\Core\Exception\SystemComponentException
* @throws \oxSystemComponentException
* @throws d3noPdfHandlerFoundException
*/
public function getCustomPdfClass(Order $order)
{
echo __CLASS__." - ".__FUNCTION__." - ".__LINE__."<br>";
$pdfInvoice= oxNew(invoicePdf::class);
$pdfInvoice->setOrder($order);
unset($order);
return $pdfInvoice;
/** @var d3noPdfHandlerFoundException $e */
$e = oxNew(d3noPdfHandlerFoundException::class, Registry::getRequest()->getRequestParameter('pdftype'));
throw($e);
}
}

View File

@ -0,0 +1,27 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
* http://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\PdfDocuments\Application\Model\Exceptions;
use OxidEsales\Eshop\Core\Exception\StandardException;
class d3noPdfHandlerFoundException extends StandardException
{
public function __construct( $requestId, $sMessage = "no pdf handler defined for given request id", $iCode = 0, \Exception $previous = null )
{
$sMessage .= '"'.$requestId.'"';
parent::__construct( $sMessage, $iCode, $previous );
}
}