src/Seo/Controller/SeoControllerController.php line 14

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace App\Seo\Controller;
  3. use App\Base\Controller\BaseController;
  4. use App\Seo\Repository\SeoSettingsRepository;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. class SeoControllerController extends BaseController
  9. {
  10.     #[Route(path'/robots.txt'name'seo:robots')]
  11.     public function index(
  12.         Request $request,
  13.         SeoSettingsRepository $repository
  14.     ): Response {
  15.         $settings $repository->getOrCreate();
  16.         $response = new Response();
  17.         $response->setContent($settings->getRobots());
  18.         $response->headers->add(['Content-Type' => 'text/plain']);
  19.         return $response;
  20.     }
  21. }