<?php

namespace External\SprintBundle\Context;

use KupShop\KupShopBundle\Context\UserContext;
use KupShop\KupShopBundle\Util\Contexts;
use KupShop\PricelistBundle\Context\PricelistContext;

class CacheContext extends \KupShop\KupShopBundle\Context\CacheContext
{
    /** @var UserContext */
    private $userContext;

    /**
     * @required
     */
    public function setUserContext(UserContext $userContext): void
    {
        $this->userContext = $userContext;
    }

    protected function getKeyAvailability(): ?array
    {
        return [UserContext::class => $this->userContext->isDealer()];
    }

    protected function getKeyDelivery(): ?array
    {
        return [UserContext::class => $this->userContext->isDealer()];
    }

    protected function getKeyFullPage(): array
    {
        return array_merge(parent::getKeyFullPage(), [
            PricelistContext::class => Contexts::get(PricelistContext::class)->getActiveId(),
        ]);
    }
}
