<?php

declare(strict_types=1);

namespace External\HannahBundle\Attachment;

use KupShop\KupShopBundle\Email\EmailGroupTypeEnum;
use KupShop\KupShopBundle\Util\System\PathFinder;
use KupShop\OrderingBundle\Attachment\BaseAttachment;
use KupShop\OrderingBundle\Exception\InvoiceException;
use Symfony\Contracts\Service\Attribute\Required;

class OCUserCardToUProfiPDFAttachment extends BaseAttachment
{
    protected static $name = '[OC] PDF Podmínky užití - PROFI';
    protected static $type = 'oc_user_card_tou_profi_pdf';
    protected static $group = EmailGroupTypeEnum::OTHER;
    protected static $priority = -10;

    private PathFinder $pathFinder;

    #[Required]
    final public function setPathFinder(PathFinder $pathFinder): void
    {
        $this->pathFinder = $pathFinder;
    }

    public function getFilename(): string
    {
        return 'Zakaznicka_karta_Podminky_uziti.pdf';
    }

    public function getContent()
    {
        $path = $this->pathFinder->dataPath('files/email-attachment/karta_PROFI.pdf');
        if (!file_exists($path)) {
            throw new InvoiceException('Cannot find source file: '.$path);
        }

        return file_get_contents($path);
    }
}
