<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class RobotsController extends AbstractController
{
    #[Route('/robots.txt', name: 'app_robots', methods: ['GET'])]
    public function index(UrlGeneratorInterface $urlGenerator): Response
    {
        $sitemapUrl = $urlGenerator->generate('app_sitemap', [], UrlGeneratorInterface::ABSOLUTE_URL);

        $content = <<<TXT
User-agent: *
Allow: /
Disallow: /admin
Disallow: /mon-compte
Disallow: /external-redirect
Disallow: /my-csp-report
Disallow: /t/
Allow: /mentions-legales
Allow: /cgu
Allow: /cgv
Allow: /hebergement
Allow: /cookies
Allow: /rgpd
Allow: /conformite
Disallow: /unsubscribe/

Sitemap: {$sitemapUrl}
TXT;

        return new Response($content, 200, [
            'Content-Type' => 'text/plain',
        ]);
    }
}
