<?php

declare(strict_types=1);

namespace KupShop\PreordersBundle\Twig;

trait ComponentsTemplateOverride
{
    public function getTemplate(): string
    {
        assert(isset($this->template));

        if (findModule(\Modules::COMPONENTS)) {
            $templateName = str_replace('.tpl', '', $this->template);

            return "@Preorders/{$templateName}.html.twig";
        }

        return $this->template;
    }

    public function getTemplates(): iterable
    {
        return [$this->getTemplate()];
    }

    public function getEntrypoint(): string
    {
        return 'preorders';
    }
}
