<?php

namespace App\Domain\Setting\Infrastructure\ApiPlatform\State\Provider;

use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProviderInterface;
use App\Domain\Setting\Application\Query\ExportContentSourceQuery;
use App\Domain\Setting\Application\QueryHandler\ExportContentSourceQueryHandler;

readonly class ExportContentSourceStateProvider implements ProviderInterface
{
    public function __construct(
        private ExportContentSourceQueryHandler $handler
    ) {
    }

    public function provide(Operation $operation, array $uriVariables = [], array $context = []): array
    {
        $query = new ExportContentSourceQuery();
        $response = $this->handler->handle($query);

        return [
            'contentSources' => $response->contentSources,
            'exportDate' => $response->exportDate,
        ];
    }
}
