From 875f8e2464f579640a44d12f0e5b75fc0003eebe Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Tue, 21 Jan 2025 10:57:38 +0100 Subject: [PATCH] cleanup --- .../Controller/orderOverviewPdfGenerator.php | 3 ++ .../AbstractClasses/pdfdocumentsGeneric.php | 37 ++++++++++++------- .../Model/Documents/invoicewithoutlogoPdf.php | 3 +- .../Model/Registries/registryAbstract.php | 3 ++ .../registryOrdermanagerActions.php | 4 ++ .../Registries/registryOrderoverview.php | 4 ++ .../d3_overview_controller_pdfdocuments.php | 5 +++ metadata.php | 6 --- 8 files changed, 45 insertions(+), 20 deletions(-) diff --git a/Application/Controller/orderOverviewPdfGenerator.php b/Application/Controller/orderOverviewPdfGenerator.php index cfa0834..130e0d8 100644 --- a/Application/Controller/orderOverviewPdfGenerator.php +++ b/Application/Controller/orderOverviewPdfGenerator.php @@ -11,6 +11,7 @@ namespace D3\PdfDocuments\Application\Controller; use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException; +use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface; use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface; use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview; use OxidEsales\Eshop\Application\Model\Order; @@ -22,6 +23,7 @@ class orderOverviewPdfGenerator * @param Order $order * @param int $iSelLang * @throws noPdfHandlerFoundException + * @throws wrongPdfGeneratorInterface */ public function generatePdf(Order $order, int $iSelLang = 0) { @@ -34,6 +36,7 @@ class orderOverviewPdfGenerator /** * @return pdfdocumentsOrderInterface * @throws noPdfHandlerFoundException + * @throws wrongPdfGeneratorInterface */ public function getPdfClass() { diff --git a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php index ed4e074..44f54f2 100644 --- a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php +++ b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php @@ -12,7 +12,6 @@ namespace D3\PdfDocuments\Application\Model\AbstractClasses; use Assert\InvalidArgumentException; use D3\PdfDocuments\Application\Model\Constants; -use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract; use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsGenericInterface as genericInterface; use OxidEsales\Eshop\Core\Base; use OxidEsales\Eshop\Core\Exception\StandardException; @@ -20,10 +19,8 @@ use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\UtilsView; use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface; -use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateEngineInterface; use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer; use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface; -use OxidEsales\Smarty\SmartyEngine; use OxidEsales\Twig\Resolver\TemplateChain\TemplateNotInChainException; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; @@ -57,11 +54,14 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface } /** - * @param $sFilename + * @param string $sFilename * @param int $iSelLang * @param string $target + * * @return string|null + * @throws ContainerExceptionInterface * @throws Html2PdfException + * @throws NotFoundExceptionInterface */ public function genPdf($sFilename, $iSelLang = 0, $target = self::PDF_DESTINATION_STDOUT) { @@ -80,6 +80,15 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface * @param int $iLanguage * @throws Html2PdfException */ + + /** + * @param $iLanguage + * + * @return void + * @throws ContainerExceptionInterface + * @throws Html2PdfException + * @throws NotFoundExceptionInterface + */ public function downloadPdf($iLanguage = 0) { try { @@ -88,17 +97,20 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface $this->genPdf($sFilename, $iLanguage, self::PDF_DESTINATION_DOWNLOAD); $this->runPostAction(); Registry::getUtils()->showMessageAndExit(''); - } catch (pdfGeneratorExceptionAbstract|InvalidArgumentException $e) { - Registry::get(UtilsView::class)->addErrorToDisplay($e); + } catch (InvalidArgumentException $e) { Registry::getLogger()->error($e); + Registry::get(UtilsView::class)->addErrorToDisplay($e); } } /** * @param string $path - * @param int $iLanguage + * @param int $iLanguage * + * @return void + * @throws ContainerExceptionInterface * @throws Html2PdfException + * @throws NotFoundExceptionInterface */ public function savePdfFile($path, $iLanguage = 0) { @@ -111,7 +123,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface self::PDF_DESTINATION_FILE ); $this->runPostAction(); - } catch (pdfGeneratorExceptionAbstract|InvalidArgumentException $e) { + } catch (InvalidArgumentException $e) { Registry::get(UtilsView::class)->addErrorToDisplay($e); Registry::getLogger()->error($e); } @@ -120,8 +132,10 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface /** * @param int $iLanguage * - * @return null|string + * @return string|null + * @throws ContainerExceptionInterface * @throws Html2PdfException + * @throws NotFoundExceptionInterface */ public function getPdfContent($iLanguage = 0) { @@ -131,7 +145,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface $ret = $this->genPdf( $sFilename, $iLanguage, self::PDF_DESTINATION_STRING ); $this->runPostAction(); return $ret; - } catch (pdfGeneratorExceptionAbstract|InvalidArgumentException $e) { + } catch (InvalidArgumentException $e) { Registry::get(UtilsView::class)->addErrorToDisplay($e); Registry::getLogger()->error($e); } @@ -139,9 +153,6 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface return null; } - /** - * @param int $iSelLang - */ public function getTemplateEngineVars(int $iSelLang): array { unset($iSelLang); diff --git a/Application/Model/Documents/invoicewithoutlogoPdf.php b/Application/Model/Documents/invoicewithoutlogoPdf.php index fb79d32..0be29d8 100644 --- a/Application/Model/Documents/invoicewithoutlogoPdf.php +++ b/Application/Model/Documents/invoicewithoutlogoPdf.php @@ -39,7 +39,8 @@ class invoicewithoutlogoPdf extends invoicePdf /** * @return string */ - public function getTemplate(){ + public function getTemplate() + { return '@d3PdfDocuments/documents/invoice/invoiceNoLogo'; } } \ No newline at end of file diff --git a/Application/Model/Registries/registryAbstract.php b/Application/Model/Registries/registryAbstract.php index ebdec22..2b3f307 100644 --- a/Application/Model/Registries/registryAbstract.php +++ b/Application/Model/Registries/registryAbstract.php @@ -28,6 +28,8 @@ abstract class registryAbstract implements registryGenericInterface /** * @param $className + * + * @throws wrongPdfGeneratorInterface */ public function addGenerator($className) { @@ -44,6 +46,7 @@ abstract class registryAbstract implements registryGenericInterface /** * @param $className * generator fully qualified class name * @param pdfdocumentsGenericInterface $item + * @throws wrongPdfGeneratorInterface */ protected function addItem($className, pdfdocumentsGenericInterface $item) { diff --git a/Application/Model/Registries/registryOrdermanagerActions.php b/Application/Model/Registries/registryOrdermanagerActions.php index 6d49370..4aa4c4d 100644 --- a/Application/Model/Registries/registryOrdermanagerActions.php +++ b/Application/Model/Registries/registryOrdermanagerActions.php @@ -14,10 +14,14 @@ use D3\PdfDocuments\Application\Model\Documents\deliverynotePdf; use D3\PdfDocuments\Application\Model\Documents\deliverynotewithoutlogoPdf; use D3\PdfDocuments\Application\Model\Documents\invoicePdf; use D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf; +use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface; use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface; class registryOrdermanagerActions extends registryAbstract implements registryOrdermanagerActionsInterface { + /** + * @throws wrongPdfGeneratorInterface + */ public function __construct() { $this->addGenerator(invoicePdf::class); diff --git a/Application/Model/Registries/registryOrderoverview.php b/Application/Model/Registries/registryOrderoverview.php index 106fa79..9190815 100644 --- a/Application/Model/Registries/registryOrderoverview.php +++ b/Application/Model/Registries/registryOrderoverview.php @@ -14,10 +14,14 @@ use D3\PdfDocuments\Application\Model\Documents\deliverynotePdf; use D3\PdfDocuments\Application\Model\Documents\deliverynotewithoutlogoPdf; use D3\PdfDocuments\Application\Model\Documents\invoicePdf; use D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf; +use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface; use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface; class registryOrderoverview extends registryAbstract implements registryOrderoverviewInterface { + /** + * @throws wrongPdfGeneratorInterface + */ public function __construct() { $this->addGenerator(invoicePdf::class); diff --git a/Modules/Application/Controller/d3_overview_controller_pdfdocuments.php b/Modules/Application/Controller/d3_overview_controller_pdfdocuments.php index c87bde2..d081e98 100644 --- a/Modules/Application/Controller/d3_overview_controller_pdfdocuments.php +++ b/Modules/Application/Controller/d3_overview_controller_pdfdocuments.php @@ -13,6 +13,7 @@ namespace D3\PdfDocuments\Modules\Application\Controller; use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator; use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException; use D3\PdfDocuments\Application\Model\Exceptions\pdfGeneratorExceptionAbstract; +use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface; use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview; use Doctrine\DBAL\Driver\Exception; use Doctrine\DBAL\Exception as DBALException; @@ -77,6 +78,10 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu } } + /** + * @return registryOrderoverview + * @throws wrongPdfGeneratorInterface + */ public function d3getGeneratorList(): registryOrderoverview { return oxNew(registryOrderoverview::class); diff --git a/metadata.php b/metadata.php index 9b02f4b..e299bd0 100644 --- a/metadata.php +++ b/metadata.php @@ -12,14 +12,8 @@ use D3\PdfDocuments\Application\Model\Constants as Constants; use D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments; use OxidEsales\Eshop\Application\Controller\Admin\OrderOverview; -/** - * Metadata version - */ $sMetadataVersion = '2.1'; -/** - * Module information - */ $aModule = [ 'id' => Constants::OXID_MODULE_ID, 'title' => [