<?php

declare(strict_types=1);

/*
 * This file is part of the Ferienpass package.
 *
 * (c) Richard Henkenjohann <richard@ferienpass.online>
 *
 * For more information visit the project website <https://ferienpass.online>
 * or the documentation under <https://docs.ferienpass.online>.
 */

namespace Ferienpass\AdminBundle\Export;

use Ferienpass\CoreBundle\Settings\PageConfigManager;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;

class SerializerContextBuilder
{
    public function __construct(
        private readonly Security $security,
        private readonly PageConfigManager $pageConfigManager
    ) {
    }

    public function build(): array
    {
        return [
            'groups' => $this->security->isGranted('ROLE_ADMIN') ? 'list:export:admin' : 'list:export:default',
            DateTimeNormalizer::FORMAT_KEY => 'd.m.Y H:i:s',
            DateTimeNormalizer::TIMEZONE_KEY => $this->pageConfigManager->getPageConfig()->getTimezone(),
        ];
    }
}
