From 7eb770440d9540a4d4fe43c1bf55929bbd4055bd Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Mon, 8 Jun 2020 16:39:33 +0200 Subject: [PATCH] add ordermanager combination --- .../AbstractClasses/pdfdocumentsGeneric.php | 26 +++++++++- .../pdfdocumentsGenericInterface.php | 7 +++ .../registryOrdermanagerActions.php | 50 +++++++++++++++++++ .../registryOrdermanagerActionsInterface.php | 26 ++++++++++ metadata.php | 3 +- 5 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 Application/Model/Registries/registryOrdermanagerActions.php create mode 100644 Application/Model/Registries/registryOrdermanagerActionsInterface.php diff --git a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php index 9009880..f589128 100644 --- a/Application/Model/AbstractClasses/pdfdocumentsGeneric.php +++ b/Application/Model/AbstractClasses/pdfdocumentsGeneric.php @@ -66,7 +66,7 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface $sFilename = $this->getFilename(); $oPdf = oxNew(Html2Pdf::class, ...$this->getPdfProperties()); $oPdf->writeHTML($this->getHTMLContent($iSelLang)); - $oPdf->output($sFilename, $target); + return $oPdf->output($sFilename, $target); } /** @@ -84,6 +84,30 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface } } + /** + * @param int $iLanguage + * + * @return null|string + * @throws Html2PdfException + */ + public function getPdfContent($iLanguage = 0) + { + try { + $sFilename = $this->getFilename(); + ob_start(); + //$this->genPdf( $sFilename, $iLanguage, self::PDF_DESTINATION_STDOUT ); + $this->genPdf( $sFilename, $iLanguage, self::PDF_DESTINATION_STRING ); + return ob_get_contents(); + } catch (pdfGeneratorExceptionAbstract $e) { + Registry::get(UtilsView::class)->addErrorToDisplay($e); + Registry::getLogger()->error($e); + } catch (\Exception $e) { + dumpvar($e->getMessage()); + } + + return null; + } + public function setSmartyVars() { $this->oSmarty->assign('oConfig', Registry::getSession()->getConfig()); diff --git a/Application/Model/Interfaces/pdfdocumentsGenericInterface.php b/Application/Model/Interfaces/pdfdocumentsGenericInterface.php index a57fa81..e2a14ed 100644 --- a/Application/Model/Interfaces/pdfdocumentsGenericInterface.php +++ b/Application/Model/Interfaces/pdfdocumentsGenericInterface.php @@ -46,6 +46,13 @@ interface pdfdocumentsGenericInterface */ public function downloadPdf($iLanguage = 0); + /** + * @param int $iLanguage + * + * @return string|null + */ + public function getPdfContent($iLanguage = 0); + /** * @param $sFilename * @param int $iSelLang diff --git a/Application/Model/Registries/registryOrdermanagerActions.php b/Application/Model/Registries/registryOrdermanagerActions.php new file mode 100644 index 0000000..5f634f2 --- /dev/null +++ b/Application/Model/Registries/registryOrdermanagerActions.php @@ -0,0 +1,50 @@ + + * @link http://www.oxidmodule.com + */ + +namespace D3\PdfDocuments\Application\Model\Registries; + +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\Interfaces\pdfdocumentsOrderInterface; + +class registryOrdermanagerActions extends registryAbstract implements registryOrdermanagerActionsInterface +{ + public function __construct() + { + $this->addGenerator(invoicePdf::class); + $this->addGenerator(deliverynotePdf::class); + $this->addGenerator(invoicewithoutlogoPdf::class); + $this->addGenerator(deliverynotewithoutlogoPdf::class); + } + + /** + * @return string + */ + public function getRequiredGeneratorInterfaceClassName() + { + return pdfdocumentsOrderInterface::class; + } + + /** + * @param $className * generator fully qualified class name + * @return pdfdocumentsOrderInterface + */ + public function getGenerator($className) + { + return $this->_aRegistry[$className]; + } +} \ No newline at end of file diff --git a/Application/Model/Registries/registryOrdermanagerActionsInterface.php b/Application/Model/Registries/registryOrdermanagerActionsInterface.php new file mode 100644 index 0000000..9bee64c --- /dev/null +++ b/Application/Model/Registries/registryOrdermanagerActionsInterface.php @@ -0,0 +1,26 @@ + + * @link http://www.oxidmodule.com + */ + +namespace D3\PdfDocuments\Application\Model\Registries; + +interface registryOrdermanagerActionsInterface extends registryGenericInterface +{ + /** + * @param $className * generator fully qualified class name + */ + public function addGenerator($className); +} \ No newline at end of file diff --git a/metadata.php b/metadata.php index 1465531..5c0684c 100644 --- a/metadata.php +++ b/metadata.php @@ -28,7 +28,7 @@ $sMetadataVersion = '2.0'; $logo = (class_exists(d3utils::class) ? d3utils::getInstance()->getD3Logo() : 'D³'); -$sModuleId = 'pdfDocuments'; +$sModuleId = 'd3PdfDocuments'; /** * Module information */ @@ -38,7 +38,6 @@ $aModule = [ 'de' => $logo.' PDF-Dokumente aus HTML-Templates', 'en' => $logo.' PDF documents from HTML templates', ], - 'thumbnail' => 'picture.png', 'version' => '1.0', 'author' => 'D³ Data Development (Inh.: Thomas Dartsch)', 'email' => 'support@shopmodule.com',