Created
February 16, 2017 15:01
-
-
Save B-Galati/446caa9ec3fc42b5828eee7a87fa253b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Manwin\YouPorn\WebFrontBundle\EventListener; | |
use Symfony\Component\HttpKernel\Event\FilterResponseEvent; | |
class FrameHeaderListener | |
{ | |
public function onKernelResponse(FilterResponseEvent $event) | |
{ | |
if (!$event->isMasterRequest()) { | |
return; | |
} | |
$response = $event->getResponse(); | |
if ($response->isRedirection()) { | |
return; | |
} | |
$currentPath = $event->getRequest()->getPathInfo() ?: '/'; | |
if (0 === strpos($currentPath, '/embed/')) { | |
return; | |
} | |
$response->headers->set('X-Frame-Options', 'DENY'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment