<?php
/**
 * MB "Vienas bitas" (Magetrend.com)
 *
 * @category MageTrend
 * @package  Magetend/PdfTemplates
 * @author   Edvinas Stulpinas <edwin@magetrend.com>
 * @license  http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * @link     https://www.magetrend.com/magento-2-pdf-invoice-pro
 */

namespace Magetrend\PdfTemplates\Model;

use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Io\File;
use Magento\Framework\App\Filesystem\DirectoryList;

/**
 * PDF Processor interface
 *
 * @category MageTrend
 * @package  Magetend/PdfTemplates
 * @author   Edvinas Stulpinas <edwin@magetrend.com>
 * @license  http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * @link     https://www.magetrend.com/magento-2-pdf-invoice-pro
 */
abstract class AdapterAbstract
{
    private $template;

    abstract public function getPdf($objects = [], $forceTemplateId = null);

    abstract public function createPdf($objects, $dir, $fileName, $templateId = null);

    public function setTemplate($template)
    {
        $this->template = $template;
    }

    public function getTemplate()
    {
        return $this->template;
    }

    public function getOrderId($object)
    {
        if ($object instanceof \Magento\Sales\Api\Data\OrderInterface) {
            return $object->getId();
        }

        $order = $object->getOrder();
        if ($order instanceof \Magento\Sales\Api\Data\OrderInterface) {
            return $order->getId();
        }

        return 0;
    }
}