![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/fooman/pdfcore-m2/src/Block/Pdf/ |
<?php /** * @copyright Copyright (c) 2015 Fooman Limited (http://www.fooman.co.nz) * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Fooman\PdfCore\Block\Pdf; use Fooman\PdfCore\Model\Template; use Magento\Framework\View\Element\Template\Context; use Magento\Framework\App\Area; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\MailException; use Magento\Framework\Filter\Input\MaliciousCode; class DocumentRenderer extends PdfAbstract implements DocumentRendererInterface { public const DEFAULT_PDF_LAYOUT_HANDLE = 'fooman_pdfcore_generic'; public const DEFAULT_FOOTER_LAYOUT_HANDLE = 'fooman_pdfcore_footer'; /** * @var MaliciousCode */ protected $maliciousCode; /** * @var Template */ protected $template; /** * @var ScopeConfigInterface */ protected $scopeConfig; /** * @param Context $context * @param MaliciousCode $maliciousCode * @param Template $template * @param array $data */ public function __construct( Context $context, MaliciousCode $maliciousCode, Template $template, array $data = [] ) { $this->maliciousCode = $maliciousCode; $this->template = $template; $this->scopeConfig = $context->getScopeConfig(); parent::__construct($context, $data); } /** * Prepare html output * * @return string * @throws LocalizedException * @throws MailException */ public function renderHtmlTemplate() { $this->template->setArea(Area::AREA_FRONTEND); $this->template->setVars($this->getTemplateVars()); $this->template->setDesignConfig( [ 'store' => $this->getStoreId(), 'area' => Area::AREA_FRONTEND ] ); //we process twice as the template processing is not recursive and we may have additional placeholders //like template or custom variables $preProcessedTemplate = $this->template->processLayout($this->getLayoutHandle()); $this->template->setTemplateText($preProcessedTemplate); return $this->template->processTemplate(); } /** * @return ScopeConfigInterface */ public function getScopeConfig() { return $this->scopeConfig; } public function getFooterLayoutHandle() { return self::DEFAULT_FOOTER_LAYOUT_HANDLE; } public function getLayoutHandle() { return self::DEFAULT_PDF_LAYOUT_HANDLE; } public function getTemplateVars() { return [ 'scope_config' => $this->getScopeConfig() ]; } public function getStoreId() { $store = $this->_storeManager->getDefaultStoreView(); return $store ? $store->getId() : null; } public function getIntegratedLabelsContent() { return null; } public function canApplyIntegratedLabelsContent() { return false; } public function getFooterContent() { $this->template->setArea(Area::AREA_FRONTEND); $this->template->setVars($this->getTemplateVars()); $this->template->setDesignConfig( [ 'store' => $this->getStoreId(), 'area' => Area::AREA_FRONTEND ] ); //we process twice as the template processing is not recursive and we may have additional placeholders //like template or custom variables $preProcessedTemplate = $this->template->processLayout($this->getFooterLayoutHandle()); $this->template->setTemplateText($preProcessedTemplate); return $this->template->processTemplate(); } public function getTitle() { return 'pdfdocs'; } public function getIncrement() { return ''; } public function getForcedPageOrientation() { return false; } }