<?php

namespace KupShop\ComponentsBundle\Twig\Components;

use KupShop\ComponentsBundle\Attributes\Component;
use KupShop\ComponentsBundle\Attributes\Version;
use KupShop\ComponentsBundle\Twig\BaseComponent;
use KupShop\KupShopBundle\Context\CacheContext;
use KupShop\KupShopBundle\Util\Contexts;
use KupShop\KupShopBundle\Util\StringUtil;
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

#[AsTwigComponent(template: '@Components/components/Footer/Footer.1.html.twig')]
#[Component(1, [
    new Version(1, newJs: null),
])]
class Footer extends BaseComponent
{
    public string $cache_key = '';

    public function getCacheKey(): string
    {
        $cacheKey = [
            Contexts::get(CacheContext::class)->getKey([
                CacheContext::TYPE_TEXT,
                CacheContext::TYPE_PRICE,
                CacheContext::TYPE_AVAILABILITY,
            ]),
            static::class,
            $this->version,
        ];

        if ($this->cache_key) {
            $cacheKey[] = $this->cache_key;
        }

        return StringUtil::slugify(implode('_', $cacheKey));
    }
}
