Skip to content

Commit

Permalink
--fix bug when disable module
Browse files Browse the repository at this point in the history
  • Loading branch information
Linhnv1902 committed Jun 28, 2022
1 parent 990a3ff commit d157869
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Controller/Index/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\Controller\Result\Redirect;
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Mageplaza\ShareCart\Api\ShareCartRepositoryInterface;
use Mageplaza\ShareCart\Helper\Data;
use Mpdf\MpdfException;

/**
Expand All @@ -49,20 +51,28 @@ class Download extends Action
*/
protected $checkoutSession;

/**
* @var Data
*/
protected $helper;

/**
* Download constructor.
*
* @param Context $context
* @param ShareCartRepositoryInterface $printProcess
* @param Session $checkoutSession
* @param Data $helper
*/
public function __construct(
Context $context,
ShareCartRepositoryInterface $printProcess,
Session $checkoutSession
Session $checkoutSession,
Data $helper
) {
$this->printProcess = $printProcess;
$this->checkoutSession = $checkoutSession;
$this->helper = $helper;

parent::__construct($context);
}
Expand All @@ -76,6 +86,12 @@ public function __construct(
*/
public function execute()
{
/** @var Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
if (!$this->helper->isEnabled()) {
$this->messageManager->addErrorMessage(__('The Share Cart extension is disable'));
return $resultRedirect->setPath('checkout/cart');
}
$mpShareCartToken = $this->checkoutSession->getQuote()->getMpShareCartToken();

$this->printProcess->downloadPdf($mpShareCartToken);
Expand Down

0 comments on commit d157869

Please sign in to comment.