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/pdfcustomiser-implementation-m2/src/Block/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/fooman/pdfcustomiser-implementation-m2/src/Block/Agreement.php
<?php
namespace Fooman\PdfCustomiser\Block;

use Fooman\PdfCore\Model\Template;
use Fooman\PdfDesign\Model\DesignProvider;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Filter\Input\MaliciousCode;
use Magento\Store\Model\Store;

/**
 * Pdf rendering class for terms and conditions
 *
 * @author     Kristof Ringleff
 * @copyright  Copyright (c) 2009 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.
 */
class Agreement extends \Fooman\PdfCore\Block\Pdf\DocumentRenderer
{

    const LAYOUT_HANDLE = 'fooman_pdfcustomiser_agreement';
    const PDF_TYPE = 'agreement';

    /**
     * @var DesignProvider
     */
    private $designProvider;

    /**
     * @var \Magento\Store\Model\StoreManagerInterface
     */
    private $storeManager;

    public function __construct(
        Context        $context,
        MaliciousCode  $maliciousCode,
        Template       $template,
        DesignProvider $designProvider,
        array          $data = []
    ) {
        $this->designProvider = $designProvider;
        $this->storeManager =  $context->getStoreManager();
        parent::__construct($context, $maliciousCode, $template, $data);
    }

    /**
     * return array of variables to be passed to the template
     *
     * @return array
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function getTemplateVars(): array
    {
        return array_merge(
            parent::getTemplateVars(),
            $this->getDesignPickVars(),
            ['pdf_design' => $this->getDesign()]
        );
    }

    protected function getDesignPickVars()
    {
        return [
            'agreement' => $this->getAgreement()
        ];
    }

    /**
     * @return \Fooman\PdfDesign\Model\Api\DesignInterface
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function getDesign()
    {
        return $this->designProvider->getDesign($this->getStoreId(), $this->getDesignPickVars());
    }

    public function getStoreId()
    {
        if ($this->getAgreement()->getStoreId() !== null) {
            return $this->getAgreement()->getStoreId();
        }
        $store = $this->storeManager->getDefaultStoreView();
        $defaultStoreViewId =  $store ? $store->getId() : Store::DEFAULT_STORE_ID;
        $stores = $this->getAgreement()->getStores();
        if ($stores === null) {
            return $defaultStoreViewId;
        }
        if (count($stores) === 1) {
            return array_shift($stores);
        }
        if (count($stores) === 2 && in_array($defaultStoreViewId, $stores)) {
            //if we have 2 stores and one of them is the default pick the other
            foreach ($stores as $storeId) {
                if ($storeId !== $defaultStoreViewId) {
                    return $storeId;
                }
            }
        }
        try {
            $currentStore = $this->storeManager->getStore();
            $currentStoreViewId = $currentStore->getId();
        } catch (\Exception $e) {
            $currentStoreViewId = false;
        }
        if (in_array($currentStoreViewId, $stores)) {
            return $currentStoreViewId;
        }
        return $defaultStoreViewId;
    }

    public function getLayoutHandle()
    {
        return static::LAYOUT_HANDLE;
    }

    public function getTitle()
    {
        return $this->getAgreement()->getName();
    }

    public function getIncrement()
    {
        return '';
    }
}

Spamworldpro Mini