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;
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 Smarty;
use Spipu\Html2Pdf\Html2Pdf;
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 int $iSelLang
@ -33,25 +45,17 @@ abstract class pdfDocuments_generic implements genericInterface
{
$sFilename = $this->getFilename( $sFilename);
$oPdf = call_user_func_array('oxNew', array_merge([Html2Pdf::class], $this->getPdfProperties()));
//$oPdf = oxNew(Html2Pdf::class, 'P', 'A4', 'de');
$oPdf = oxNew(Html2Pdf::class, ...$this->getPdfProperties());
$oPdf->writeHTML($this->getHTMLContent($iSelLang));
$oPdf->output($sFilename, $target);
}
/**
* @param Smarty $smarty
*
* @return Smarty
*/
public function setSmartyVars($smarty)
public function setSmartyVars()
{
$smarty->assign('oConfig', Registry::getSession()->getConfig());
$smarty->assign('oViewConf', Registry::getSession()->getConfig()->getActiveView()->getViewConfig());
$smarty->assign('shop', Registry::getSession()->getConfig()->getActiveShop());
$smarty->assign('lang', Registry::getLang());
return $smarty;
$this->oSmarty->assign('oConfig', Registry::getSession()->getConfig());
$this->oSmarty->assign('oViewConf', Registry::getSession()->getConfig()->getActiveView()->getViewConfig());
$this->oSmarty->assign('shop', Registry::getSession()->getConfig()->getActiveShop());
$this->oSmarty->assign('lang', Registry::getLang());
}
/**
@ -73,15 +77,12 @@ abstract class pdfDocuments_generic implements genericInterface
{
$lang = Registry::getLang();
/** @var Smarty $oSmarty */
$oSmarty = Registry::getUtilsView()->getSmarty();
$currTplLang = $lang->getTplLanguage();
$lang->setTplLanguage($iSelLang);
$oSmarty = $this->setSmartyVars($oSmarty);
$this->setSmartyVars();
$content = $oSmarty->fetch($this->getTemplate());
$content = $this->oSmarty->fetch($this->getTemplate());
$lang->setTplLanguage($currTplLang);

View File

@ -17,11 +17,10 @@
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\Payment;
use OxidEsales\Eshop\Application\Model\User;
use Smarty;
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;
}
/**
* @param Smarty $smarty
*
* @return Smarty
*/
public function setSmartyVars($smarty)
public function setSmartyVars()
{
$smarty = parent::setSmartyVars($smarty);
parent::setSmartyVars();
$smarty->assign('order', $this->getOrder());
$this->oSmarty->assign('order', $this->getOrder());
$oUser = oxNew(User::Class);
$oUser->load($this->getOrder()->getFieldData('oxuserid'));
$smarty->assign('user', $oUser);
$this->oSmarty->assign('user', $oUser);
$oPayment = oxNew(Payment::class);
$oPayment->load($this->getOrder()->getFieldData('oxpaymenttype'));
$smarty->assign('payment', $oPayment);
return $smarty;
$this->oSmarty->assign('payment', $oPayment);
}
/**

View File

@ -18,9 +18,9 @@
namespace D3\PdfDocuments\Modules\Application\Model\Documents;
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;

View File

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

View File

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

View File

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

View File

@ -17,7 +17,7 @@
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\deliverynotePdf;
use OxidEsales\Eshop\Core\Registry;

View File

@ -30,7 +30,9 @@
}
},
"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": {
"psr-4": {