Spamworldpro Mini Shell
Spamworldpro


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/Column/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/fooman/pdfcore-m2/src/Block/Pdf/Column/QrCode.php
<?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\Column;

class QrCode extends \Fooman\PdfCore\Block\Pdf\Column implements \Fooman\PdfCore\Block\Pdf\ColumnInterface
{
    public const DEFAULT_WIDTH = 20;
    public const DEFAULT_TITLE = 'QR Code';
    public const COLUMN_TYPE = 'fooman_qrCode';
    public const XML_PATH_QR_CODE_ATTRIBUTE = 'sales_pdf/all/qr_source';

    /**
     * @var \Magento\Catalog\Api\ProductRepositoryInterface
     */
    protected $productRepository;

    /**
     * @var \Fooman\PdfCore\Helper\ParamKey
     */
    protected $paramKeyHelper;

    public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        \Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
        \Fooman\PdfCore\Helper\ParamKey $paramKeyHelper,
        array $data = []
    ) {
        $this->productRepository = $productRepository;
        $this->paramKeyHelper = $paramKeyHelper;
        parent::__construct($context, $data);
    }

    public function getGetter()
    {
        return [$this, 'getQrCode'];
    }

    public function getQrCode($row)
    {
        $qrAttribute = $this->getQrAttribute($row);
        $barcodeParams = [
            $this->escapeHtml($qrAttribute),
            'QRCODE,H',
            //the parameters below refer to x, y, width, and height of the barcode respectively
            '', '', '35', '15'
        ];
        return sprintf(
            '<table><tr><td height="15mm"><tcpdf method="write2DBarcode" %s /></td></tr></table>',
            $this->paramKeyHelper->getEncodedParams($barcodeParams)
        );
    }

    public function getQrAttribute($row)
    {
        $attribute = $this->_scopeConfig->getValue(
            self::XML_PATH_QR_CODE_ATTRIBUTE,
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE
        );
        if ($attribute === 'sku') {
            return $row->getDataUsingMethod($attribute);
        }
        try {
            $product = $this->productRepository->getById($row->getProductId(), false, $row->getStoreId());
            $qrAttribute = $product->getData($attribute);
        } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
            $qrAttribute = $row->getDataUsingMethod($attribute);
        }
        return $qrAttribute;
    }
}

Spamworldpro Mini