<?php
namespace B2bOffer\Subscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class ResponseSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
KernelEvents::RESPONSE => 'setXFrameOptions',
];
}
public function setXFrameOptions(ResponseEvent $event): void
{
if($event->getRequest()->attributes->get('allow_x_frame_options', false)) {
$event->getResponse()->headers->set('X-Frame-Options', '*');
}
}
}