set missing requirements, refactor class structure

This commit is contained in:
Daniel Seifert 2020-05-28 12:21:11 +02:00
parent 98a34d05f3
commit 18a15906e2
8 changed files with 36 additions and 41 deletions

View File

@ -17,13 +17,25 @@
namespace D3\PdfDocuments\Application\Model\AbstractClasses; namespace D3\PdfDocuments\Application\Model\AbstractClasses;
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocuments_generic as genericInterface; use D3\PdfDocuments\Application\Model\Interfaces\pdfdocuments_generic_interface as genericInterface;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
use Smarty; use Smarty;
use Spipu\Html2Pdf\Html2Pdf; use Spipu\Html2Pdf\Html2Pdf;
abstract class pdfDocuments_generic implements genericInterface abstract class pdfDocuments_generic implements genericInterface
{ {
/** @var Smarty */
public $oSmarty;
/**
* pdfDocuments_generic constructor.
*/
public function __construct()
{
/** @var Smarty $oSmarty */
$this->oSmarty = Registry::getUtilsView()->getSmarty();
}
/** /**
* @param $sFilename * @param $sFilename
* @param int $iSelLang * @param int $iSelLang
@ -33,25 +45,17 @@ abstract class pdfDocuments_generic implements genericInterface
{ {
$sFilename = $this->getFilename( $sFilename); $sFilename = $this->getFilename( $sFilename);
$oPdf = call_user_func_array('oxNew', array_merge([Html2Pdf::class], $this->getPdfProperties())); $oPdf = oxNew(Html2Pdf::class, ...$this->getPdfProperties());
//$oPdf = oxNew(Html2Pdf::class, 'P', 'A4', 'de');
$oPdf->writeHTML($this->getHTMLContent($iSelLang)); $oPdf->writeHTML($this->getHTMLContent($iSelLang));
$oPdf->output($sFilename, $target); $oPdf->output($sFilename, $target);
} }
/** public function setSmartyVars()
* @param Smarty $smarty
*
* @return Smarty
*/
public function setSmartyVars($smarty)
{ {
$smarty->assign('oConfig', Registry::getSession()->getConfig()); $this->oSmarty->assign('oConfig', Registry::getSession()->getConfig());
$smarty->assign('oViewConf', Registry::getSession()->getConfig()->getActiveView()->getViewConfig()); $this->oSmarty->assign('oViewConf', Registry::getSession()->getConfig()->getActiveView()->getViewConfig());
$smarty->assign('shop', Registry::getSession()->getConfig()->getActiveShop()); $this->oSmarty->assign('shop', Registry::getSession()->getConfig()->getActiveShop());
$smarty->assign('lang', Registry::getLang()); $this->oSmarty->assign('lang', Registry::getLang());
return $smarty;
} }
/** /**
@ -73,15 +77,12 @@ abstract class pdfDocuments_generic implements genericInterface
{ {
$lang = Registry::getLang(); $lang = Registry::getLang();
/** @var Smarty $oSmarty */
$oSmarty = Registry::getUtilsView()->getSmarty();
$currTplLang = $lang->getTplLanguage(); $currTplLang = $lang->getTplLanguage();
$lang->setTplLanguage($iSelLang); $lang->setTplLanguage($iSelLang);
$oSmarty = $this->setSmartyVars($oSmarty); $this->setSmartyVars();
$content = $oSmarty->fetch($this->getTemplate()); $content = $this->oSmarty->fetch($this->getTemplate());
$lang->setTplLanguage($currTplLang); $lang->setTplLanguage($currTplLang);

View File

@ -17,11 +17,10 @@
namespace D3\PdfDocuments\Application\Model\AbstractClasses; namespace D3\PdfDocuments\Application\Model\AbstractClasses;
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocuments_order as orderInterface; use D3\PdfDocuments\Application\Model\Interfaces\pdfdocuments_order_interface 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\Payment;
use OxidEsales\Eshop\Application\Model\User; use OxidEsales\Eshop\Application\Model\User;
use Smarty;
abstract class pdfDocuments_order extends pdfDocuments_generic implements orderInterface abstract class pdfDocuments_order extends pdfDocuments_generic implements orderInterface
{ {
@ -44,26 +43,19 @@ abstract class pdfDocuments_order extends pdfDocuments_generic implements orderI
return $this->oOrder; return $this->oOrder;
} }
/** public function setSmartyVars()
* @param Smarty $smarty
*
* @return Smarty
*/
public function setSmartyVars($smarty)
{ {
$smarty = parent::setSmartyVars($smarty); parent::setSmartyVars();
$smarty->assign('order', $this->getOrder()); $this->oSmarty->assign('order', $this->getOrder());
$oUser = oxNew(User::Class); $oUser = oxNew(User::Class);
$oUser->load($this->getOrder()->getFieldData('oxuserid')); $oUser->load($this->getOrder()->getFieldData('oxuserid'));
$smarty->assign('user', $oUser); $this->oSmarty->assign('user', $oUser);
$oPayment = oxNew(Payment::class); $oPayment = oxNew(Payment::class);
$oPayment->load($this->getOrder()->getFieldData('oxpaymenttype')); $oPayment->load($this->getOrder()->getFieldData('oxpaymenttype'));
$smarty->assign('payment', $oPayment); $this->oSmarty->assign('payment', $oPayment);
return $smarty;
} }
/** /**

View File

@ -18,9 +18,9 @@
namespace D3\PdfDocuments\Modules\Application\Model\Documents; namespace D3\PdfDocuments\Modules\Application\Model\Documents;
use D3\PdfDocuments\Application\Model\AbstractClasses\pdfDocuments_order; use D3\PdfDocuments\Application\Model\AbstractClasses\pdfDocuments_order;
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocuments_orderinvoice; use D3\PdfDocuments\Application\Model\Interfaces\pdfdocuments_orderinvoice_interface;
class invoicePdf extends pdfDocuments_order implements pdfdocuments_orderinvoice class invoicePdf extends pdfDocuments_order implements pdfdocuments_orderinvoice_interface
{ {
protected $blIsNewOrder = false; protected $blIsNewOrder = false;

View File

@ -17,7 +17,7 @@
namespace D3\PdfDocuments\Application\Model\Interfaces; namespace D3\PdfDocuments\Application\Model\Interfaces;
interface pdfdocuments_generic interface pdfdocuments_generic_interface
{ {
/** /**
* @return string * @return string

View File

@ -19,7 +19,7 @@ namespace D3\PdfDocuments\Application\Model\Interfaces;
use OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Application\Model\Order;
interface pdfdocuments_order extends pdfdocuments_generic interface pdfdocuments_order_interface extends pdfdocuments_generic_interface
{ {
/** /**
* @param Order $order * @param Order $order

View File

@ -17,7 +17,7 @@
namespace D3\PdfDocuments\Application\Model\Interfaces; namespace D3\PdfDocuments\Application\Model\Interfaces;
interface pdfdocuments_orderinvoice extends pdfdocuments_order interface pdfdocuments_orderinvoice_interface extends pdfdocuments_order_interface
{ {
public function setInvoiceNumber(); public function setInvoiceNumber();

View File

@ -17,7 +17,7 @@
namespace D3\PdfDocuments\Modules\Application\Model; namespace D3\PdfDocuments\Modules\Application\Model;
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocuments_order as OrderPdfInterface; use D3\PdfDocuments\Application\Model\Interfaces\pdfdocuments_orderInterface as OrderPdfInterface;
use D3\PdfDocuments\Modules\Application\Model\Documents\invoicePdf; use D3\PdfDocuments\Modules\Application\Model\Documents\invoicePdf;
use D3\PdfDocuments\Modules\Application\Model\Documents\deliverynotePdf; use D3\PdfDocuments\Modules\Application\Model\Documents\deliverynotePdf;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;

View File

@ -30,7 +30,9 @@
} }
}, },
"require": { "require": {
"oxid-esales/oxideshop-ce": "6.0 - 6.3" "php": ">=5.6",
"oxid-esales/oxideshop-ce": "6.0 - 6.3",
"spipu/html2pdf": "^5.2"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {