<?php
declare(strict_types=1);
namespace App\Robots;
use App\Renderer\ResponseCreatedByPageRenderer;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class AddRobotsToResponseOnResponseCreatedByPageRenderer implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
ResponseCreatedByPageRenderer::class => 'addRobots',
];
}
public function addRobots(ResponseCreatedByPageRenderer $event): void
{
$robots = Robots::getRobots($event->getPage(), $event->getEntity());
$event->getResponse()->headers->set(Robots::ROBOT_HEADER_TAG, $robots->value);
}
}