refactoring
This commit is contained in:
parent
766d857cb2
commit
f183c61c57
@ -5,6 +5,7 @@ namespace D3\Devhelper\Application\Controller;
|
||||
use D3\Devhelper\Modules\Application\Controller as ModuleController;
|
||||
use D3\Devhelper\Modules\Core as ModuleCore;
|
||||
use Exception;
|
||||
use GuzzleHttp\Psr7\ServerRequest;
|
||||
use OxidEsales\Eshop\Application\Controller\FrontendController;
|
||||
use OxidEsales\Eshop\Application\Controller\ThankYouController;
|
||||
use OxidEsales\Eshop\Application\Model\User;
|
||||
@ -13,6 +14,9 @@ use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
||||
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
|
||||
use OxidEsales\Eshop\Core\Exception\UserException;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||
|
||||
/**
|
||||
* This Software is the property of Data Development and is protected
|
||||
@ -38,15 +42,16 @@ class d3dev extends FrontendController
|
||||
parent::init();
|
||||
}
|
||||
|
||||
protected function _authenticate ()
|
||||
protected function _authenticate (): void
|
||||
{
|
||||
try {
|
||||
$sUser = Registry::getRequest()->getRequestEscapedParameter('usr');
|
||||
$sPassword = Registry::getRequest()->getRequestEscapedParameter('pwd');
|
||||
|
||||
if ( !$sUser || !$sPassword ) {
|
||||
$sUser = $_SERVER[ 'PHP_AUTH_USER' ];
|
||||
$sPassword = $_SERVER[ 'PHP_AUTH_PW' ];
|
||||
$request = ServerRequest::fromGlobals();
|
||||
$sUser = $request->getServerParams()['PHP_AUTH_USER'];
|
||||
$sPassword = $request->getServerParams()['PHP_AUTH_PW'];
|
||||
}
|
||||
|
||||
if ( !$sUser || !$sPassword ) {
|
||||
@ -65,15 +70,15 @@ class d3dev extends FrontendController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$oUser = oxNew( User::class );
|
||||
if ( !$sUser || !$sPassword || !$oUser->login( $sUser, $sPassword ) ) {
|
||||
throw oxNew( UserException::class, 'EXCEPTION_USER_NOVALIDLOGIN' );
|
||||
}
|
||||
}
|
||||
catch ( Exception $oEx ) {
|
||||
} catch ( Exception ) {
|
||||
$oShop = Registry::getConfig()->getActiveShop();
|
||||
header( 'WWW-Authenticate: Basic realm="' . $oShop->getFieldData('oxname') . '"' );
|
||||
header( 'HTTP/1.0 401 Unauthorized' );
|
||||
http_response_code(401);
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
@ -85,9 +90,11 @@ class d3dev extends FrontendController
|
||||
public function showOrderMailContent()
|
||||
{
|
||||
header('Content-type: text/html; charset='.Registry::getLang()->translateString('charset'));
|
||||
/** @var ModuleSettingService $moduleSettingService */
|
||||
$moduleSettingService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
|
||||
|
||||
if (Registry::getConfig()->getActiveShop()->isProductiveMode()
|
||||
|| false == Registry::getConfig()->getConfigParam(ModuleCore\d3_dev_conf::OPTION_SHOWMAILSINBROWSER)
|
||||
if ( Registry::getConfig()->getActiveShop()->isProductiveMode()
|
||||
|| ! $moduleSettingService->getBoolean( ModuleCore\d3_dev_conf::OPTION_SHOWMAILSINBROWSER, 'd3dev' )
|
||||
) {
|
||||
Registry::getUtils()->redirect(Registry::getConfig()->getShopUrl().'index.php?cl=start');
|
||||
}
|
||||
|
@ -17,15 +17,17 @@
|
||||
|
||||
namespace D3\Devhelper\Modules\Application\Model;
|
||||
|
||||
use Doctrine\DBAL\Query\QueryBuilder;
|
||||
use oxarticleinputexception;
|
||||
use OxidEsales\Eshop\Application\Model\Basket;
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
use OxidEsales\Eshop\Application\Model\Voucher;
|
||||
use OxidEsales\Eshop\Core\DatabaseProvider;
|
||||
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
||||
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
|
||||
use OxidEsales\Eshop\Core\Model\ListModel;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
|
||||
use oxnoarticleexception;
|
||||
|
||||
class d3_dev_oxorder extends d3_dev_oxorder_parent
|
||||
@ -36,7 +38,7 @@ class d3_dev_oxorder extends d3_dev_oxorder_parent
|
||||
public function d3DevGetOrderBasket()
|
||||
{
|
||||
/** @var d3_dev_oxbasket $oBasket */
|
||||
$oBasket = $this->_getOrderBasket();
|
||||
$oBasket = $this->getOrderBasket();
|
||||
|
||||
// add this order articles to basket and recalculate basket
|
||||
$this->_d3AddOrderArticlesToBasket($oBasket, $this->getOrderArticles());
|
||||
@ -45,7 +47,7 @@ class d3_dev_oxorder extends d3_dev_oxorder_parent
|
||||
$oBasket->calculateBasket(true);
|
||||
$oBasket->d3ClearBasketItemArticles();
|
||||
|
||||
$this->_oPayment = $this->_setPayment($oBasket->getPaymentId());
|
||||
$this->_oPayment = $this->setPayment($oBasket->getPaymentId());
|
||||
|
||||
return $oBasket;
|
||||
}
|
||||
@ -56,20 +58,36 @@ class d3_dev_oxorder extends d3_dev_oxorder_parent
|
||||
*/
|
||||
public function d3getLastOrderId()
|
||||
{
|
||||
/** @var QueryBuilder $qb */
|
||||
$qb = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
||||
$qb->select('oxid')
|
||||
->from((oxNew(Order::class))->getViewName())
|
||||
->where(
|
||||
$qb->expr()->and(
|
||||
$qb->expr()->eq(
|
||||
'oxuserid',
|
||||
$qb->createNamedParameter('')
|
||||
),
|
||||
$qb->expr()->eq(
|
||||
'oxshopid',
|
||||
$qb->createNamedParameter(Registry::getConfig()->getShopId())
|
||||
)
|
||||
)
|
||||
)
|
||||
->orderBy('oxorderdate', 'DESC')
|
||||
->setMaxResults(1);
|
||||
|
||||
$orderNr = (int) Registry::getRequest()->getRequestEscapedParameter('d3ordernr');
|
||||
$sWhere = 1;
|
||||
$parameters = [];
|
||||
if ($orderNr) {
|
||||
$sWhere = ' oxordernr = ? ';
|
||||
$parameters[] = $orderNr;
|
||||
$qb->andWhere(
|
||||
$qb->expr()->eq(
|
||||
'oxordernr',
|
||||
$orderNr
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$sSelect = "SELECT oxid FROM ".oxNew(Order::class)->getViewName()." WHERE ".
|
||||
"oxuserid != '' AND ".
|
||||
"oxshopid = ".Registry::getConfig()->getShopId()." AND ".
|
||||
$sWhere." ORDER BY oxorderdate DESC LIMIT 1";
|
||||
|
||||
return DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getOne($sSelect, $parameters);
|
||||
return $qb->execute()->fetchOne();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,12 +120,17 @@ class d3_dev_oxorder extends d3_dev_oxorder_parent
|
||||
*/
|
||||
protected function _d3AddVouchers()
|
||||
{
|
||||
$sSelect = "SELECT oxid FROM ".oxNew(Voucher::class)->getViewName()." WHERE oxorderid = ?";
|
||||
|
||||
$aResult = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC)->getAll(
|
||||
$sSelect,
|
||||
[$this->getId()]
|
||||
);
|
||||
/** @var QueryBuilder $qb */
|
||||
$qb = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
||||
$qb->select('oxid')
|
||||
->from((oxNew(Voucher::class))->getViewName())
|
||||
->where(
|
||||
$qb->expr()->eq(
|
||||
'oxorderid',
|
||||
$qb->createNamedParameter($this->getId())
|
||||
)
|
||||
);
|
||||
$aResult = $qb->execute()->fetchAllAssociative();
|
||||
|
||||
foreach ($aResult as $aFields) {
|
||||
$oVoucher = oxNew(Voucher::class);
|
||||
|
@ -54,13 +54,13 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent
|
||||
|
||||
$myConfig = Registry::getConfig();
|
||||
|
||||
$oShop = $this->_getShop();
|
||||
$oShop = $this->getShop();
|
||||
|
||||
// cleanup
|
||||
$this->_clearMailer();
|
||||
$this->clearMailer();
|
||||
|
||||
// add user defined stuff if there is any
|
||||
$oOrder = $this->_addUserInfoOrderEMail($oOrder);
|
||||
$oOrder = $this->addUserInfoOrderEMail($oOrder);
|
||||
|
||||
$oUser = $oOrder->getOrderUser();
|
||||
$this->setUser($oUser);
|
||||
@ -75,7 +75,7 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent
|
||||
// if running shop language is different from admin lang. set in config
|
||||
// we have to load shop in config language
|
||||
if ($oShop->getLanguage() != $iOrderLang) {
|
||||
$oShop = $this->_getShop($iOrderLang);
|
||||
$oShop = $this->getShop($iOrderLang);
|
||||
}
|
||||
|
||||
$this->setSmtp($oShop);
|
||||
@ -84,9 +84,14 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent
|
||||
$this->setViewData("order", $oOrder);
|
||||
|
||||
// Process view data array through oxoutput processor
|
||||
$this->_processViewArray();
|
||||
$this->processViewArray();
|
||||
|
||||
$renderer = $this->getRenderer();
|
||||
|
||||
$templateExtension = ContainerFactory::getInstance()->getContainer()
|
||||
->getParameter('oxid_esales.templating.engine_template_extension');
|
||||
$sTpl .= '.'.$templateExtension;
|
||||
|
||||
return $renderer->renderTemplate($myConfig->getTemplatePath($sTpl, false), $this->getViewData());
|
||||
}
|
||||
|
||||
@ -100,7 +105,7 @@ class d3_dev_oxemail extends d3_dev_oxemail_parent
|
||||
{
|
||||
$bridge = ContainerFactory::getInstance()->getContainer()
|
||||
->get(TemplateRendererBridgeInterface::class);
|
||||
$bridge->setEngine($this->_getSmarty());
|
||||
// $bridge->setEngine($this->getSmarty());
|
||||
|
||||
return $bridge->getTemplateRenderer();
|
||||
}
|
||||
|
@ -27,7 +27,8 @@
|
||||
"GPL-3.0-or-later"
|
||||
],
|
||||
"require": {
|
||||
"oxid-esales/oxideshop-ce": "^7.0"
|
||||
"oxid-esales/oxideshop-ce": "^7.0",
|
||||
"guzzlehttp/psr7": "^2.6"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user