<?php


namespace AutoAdmin\Bundle\Content\Profiler;


use AutoAdmin\Bundle\Content\Context\SiteContext;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Throwable;

class SiteContextCollector extends DataCollector
{
    private SiteContext $context;

    public function __construct(SiteContext $context)
    {
        $this->context = $context;
    }

    public function collect(Request $request, Response $response, Throwable $exception = null)
    {
        $this->data = [
            'site' => $this->context->getSite(),
            'domain' => $this->context->getDomain(),
            'locale' => $this->context->getLocale(),
        ];
    }

    public function getSite()
    {
        return $this->data['site'];
    }

    public function getDomain()
    {
        return $this->data['domain'];
    }

    public function getLocale()
    {
        return $this->data['locale'];
    }

    public function reset()
    {
        $this->data = [];
    }

    public function getName(): string
    {
        return 'aa_content.site_context_collector';
    }

}
