improve code

This commit is contained in:
2025-05-21 21:37:59 +02:00
parent 77cf661b05
commit 22f9b2b34b
9 changed files with 60 additions and 82 deletions

View File

@ -17,7 +17,6 @@ namespace D3\PdfDocuments\Application\Controller;
use D3\PdfDocuments\Application\Model\Constants;
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 D3\PdfDocuments\Application\Model\Registries\registryOrderoverviewInterface;
@ -32,8 +31,9 @@ use Psr\Container\NotFoundExceptionInterface;
class orderOverviewPdfGenerator
{
/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws noPdfHandlerFoundException
* @throws wrongPdfGeneratorInterface
*/
public function generatePdf(Order $order, int $iSelLang = 0): void
{
@ -51,7 +51,6 @@ class orderOverviewPdfGenerator
}
/**
* @throws wrongPdfGeneratorInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws noPdfHandlerFoundException

View File

@ -34,7 +34,7 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
public ?Order $order = null;
/**
* don't use order as constructor argument because of same method interface for all document types
* don't use order as constructor argument because of the same method interface for all document types
* @codeCoverageIgnore
*/
public function __construct()
@ -106,7 +106,6 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
}
/**
* @return int
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws ModuleSettingNotFountException
@ -126,6 +125,11 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
);
}
/**
* @throws ContainerExceptionInterface
* @throws ModuleSettingNotFountException
* @throws NotFoundExceptionInterface
*/
public function getPayableUntilDate(): false|int
{
$startDate = $this->getOrder()->getFieldData('oxbilldate');

View File

@ -15,7 +15,6 @@ declare(strict_types=1);
namespace D3\PdfDocuments\Application\Model\Registries;
use Assert\Assert;
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsGenericInterface;
use OxidEsales\Eshop\Core\Exception\StandardException;
@ -40,7 +39,6 @@ abstract class registryAbstract implements registryGenericInterface
if (!$this->hasGenerator($className)) {
/** @var pdfdocumentsGenericInterface $generator */
$generator = oxNew($className);
$this->addItem($generator);
} else {
throw oxNew(StandardException::class, 'generator still exists in registry');

View File

@ -15,39 +15,11 @@ declare(strict_types=1);
namespace D3\PdfDocuments\Application\Model\Registries;
use D3\PdfDocuments\Application\Model\Constants;
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;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
class registryOrdermanagerActions extends registryAbstract implements registryOrdermanagerActionsInterface
{
/**
* @throws wrongPdfGeneratorInterface
*/
public function __construct()
{
/** @var ModuleSettingService $settingsService */
$settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
if ($settingsService->getBoolean('d3PdfDocumentsDocInvoice', Constants::OXID_MODULE_ID)) {
$this->addGenerator(invoicePdf::class);
}
if ($settingsService->getBoolean('d3PdfDocumentsDocDeliveryNote', Constants::OXID_MODULE_ID)) {
$this->addGenerator(deliverynotePdf::class);
}
if ($settingsService->getBoolean('d3PdfDocumentsDocInvoiceNoLogo', Constants::OXID_MODULE_ID)) {
$this->addGenerator(invoicewithoutlogoPdf::class);
}
if ($settingsService->getBoolean('d3PdfDocumentsDocDeliveryNoteNoLogo', Constants::OXID_MODULE_ID)) {
$this->addGenerator(deliverynotewithoutlogoPdf::class);
}
}
use registryTrait;
/**
* @codeCoverageIgnore

View File

@ -15,43 +15,11 @@ declare(strict_types=1);
namespace D3\PdfDocuments\Application\Model\Registries;
use D3\PdfDocuments\Application\Model\Constants;
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;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class registryOrderoverview extends registryAbstract implements registryOrderoverviewInterface
{
/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws wrongPdfGeneratorInterface
*/
public function __construct()
{
/** @var ModuleSettingService $settingsService */
$settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
if ($settingsService->getBoolean('d3PdfDocumentsDocInvoice', Constants::OXID_MODULE_ID)) {
$this->addGenerator(invoicePdf::class);
}
if ($settingsService->getBoolean('d3PdfDocumentsDocDeliveryNote', Constants::OXID_MODULE_ID)) {
$this->addGenerator(deliverynotePdf::class);
}
if ($settingsService->getBoolean('d3PdfDocumentsDocInvoiceNoLogo', Constants::OXID_MODULE_ID)) {
$this->addGenerator(invoicewithoutlogoPdf::class);
}
if ($settingsService->getBoolean('d3PdfDocumentsDocDeliveryNoteNoLogo', Constants::OXID_MODULE_ID)) {
$this->addGenerator(deliverynotewithoutlogoPdf::class);
}
}
use registryTrait;
/**
* @codeCoverageIgnore

View File

@ -0,0 +1,41 @@
<?php
namespace D3\PdfDocuments\Application\Model\Registries;
use D3\PdfDocuments\Application\Model\Constants;
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 OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
trait registryTrait
{
/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws wrongPdfGeneratorInterface
*/
public function __construct()
{
/** @var ModuleSettingService $settingsService */
$settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
if ($settingsService->getBoolean('d3PdfDocumentsDocInvoice', Constants::OXID_MODULE_ID)) {
$this->addGenerator(invoicePdf::class);
}
if ($settingsService->getBoolean('d3PdfDocumentsDocDeliveryNote', Constants::OXID_MODULE_ID)) {
$this->addGenerator(deliverynotePdf::class);
}
if ($settingsService->getBoolean('d3PdfDocumentsDocInvoiceNoLogo', Constants::OXID_MODULE_ID)) {
$this->addGenerator(invoicewithoutlogoPdf::class);
}
if ($settingsService->getBoolean('d3PdfDocumentsDocDeliveryNoteNoLogo', Constants::OXID_MODULE_ID)) {
$this->addGenerator(deliverynotewithoutlogoPdf::class);
}
}
}

View File

@ -18,8 +18,6 @@ use Assert\InvalidArgumentException;
use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator;
use D3\PdfDocuments\Application\Model\Constants;
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 D3\PdfDocuments\Application\Model\Registries\registryOrderoverviewInterface;
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
@ -118,7 +116,8 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
/**
* @throws noPdfHandlerFoundException
* @throws pdfGeneratorExceptionAbstract
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function d3CreatePDF(): void
{
@ -162,7 +161,8 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
/**
* @return registryOrderoverview
* @throws wrongPdfGeneratorInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @codeCoverageIgnore
*/
public function d3getGeneratorList(): registryOrderoverview

View File

@ -15,7 +15,7 @@ Create a wide variety of static or dynamic PDF documents at the touch of a butto
At the orders of your OXID shop you have the option of creating an invoice and delivery note.
The module can be easily extended to adapt existing documents or add new ones. Even completely different document types (e.g. article data sheets) are possible.
The module can be easily extended to adapt existing documents or add new ones. Even completely different document types (e.g. article data sheets or pick lists) are possible.
## System requirements:
@ -25,9 +25,7 @@ The module can be easily extended to adapt existing documents or add new ones. E
## Compatibility:
The module contains the same functionality as the 'OXID Invoice PDF' module. Basically, both modules can be installed in parallel in the shop, if required.
If the `OXID Invoice PDF` module is to be completely replaced by the `D3 PDF Documents` module (e.g. because third modules also use its function), we provide [a customization](https://packagist.org/packages/d3/pdfdocuments_compat) which is installed additionally.
The module contains the same functionality as the former 'OXID Invoice PDF' module.
## Installation:

View File

@ -9,13 +9,13 @@
![D3 Logo & PDF Dokumente Logo](assets/picture.svg)
PDF-Dokumentgenerator für OXID eShop
**PDF-Dokumentgenerator für OXID eShop**
Erstellen Sie unterschiedliche statische oder dynamische PDF-Dokumente auf Knopfdruck. Der Dokumentinhalt wird aus Templates (Smarty bzw. Twig) erstellt.
An den Bestellungen Ihres OXID-Shops steht Ihnen die Erstellung von Rechnung und Lieferschein zur Verfügung.
Das Modul kann einfach erweitert werden, um bestehende Dokumente anzupassen oder neue hinzuzufügen. Auch komplett andere Dokumentarten (z.B. Artikeldatenblätter) sind einfach möglich.
Das Modul kann einfach erweitert werden, um bestehende Dokumente anzupassen oder neue hinzuzufügen. Auch komplett andere Dokumentarten (z.B. Artikeldatenblätter oder Picklisten) sind einfach möglich.
## Systemanforderungen:
@ -25,9 +25,7 @@ Das Modul kann einfach erweitert werden, um bestehende Dokumente anzupassen oder
## Kompatibilität:
Das Modul enthält die selbe Funktionalität wie das `OXID Invoice-PDF`-Modul. Grundsätzlich können beide Module parallel im Shop installiert werden, wenn dies erforderlich ist.
Soll das `OXID Invoice-PDF`-Modul komplett vom `PDF Dokumente` Modul ersetzt werden (weil z.B. dritte Module ebenfalls dessen Funktion verwenden), stellen wir [eine Anpassung](https://packagist.org/packages/d3/pdfdocuments_compat) zur Verfügung, die zusätzlich installiert wird.
Das Modul enthält die selbe Funktionalität wie das ehemalige `OXID Invoice-PDF`-Modul.
## Installation: