<?php

declare(strict_types=1);

/*
 * This file is part of the VITICORE2 package.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CpCreation\VitiCore\Bridge\Symfony\Bundle\Controller\Site;

use CpCreation\VitiCore\Marketing\Repository\ReviewRequestConfigurationRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

final class ProductReviewPolicyController extends AbstractController
{
    public function __construct(
        private readonly ReviewRequestConfigurationRepository $configurationRepository,
    ) {}

    public function __invoke(Request $request): Response
    {
        $configuration = $this->configurationRepository->findOne();

        return $this->render('marketing/review/policy.html.twig', [
            'moderation_enabled' => $configuration?->isModerationRequired() ?? true,
            'policy_additional_content' => $configuration?->getPolicyAdditionalContentForLocale(
                $request->getLocale(),
            ),
        ]);
    }
}
