You are here

public function RemoveXFrameOptionsSubscriber::RemoveXFrameOptions in LTI Tool Provider 2.x

Same name and namespace in other branches
  1. 8 src/EventSubscriber/RemoveXFrameOptionsSubscriber.php \Drupal\lti_tool_provider\EventSubscriber\RemoveXFrameOptionsSubscriber::RemoveXFrameOptions()

@todo Only add ResponseEvent typing to $event once D8 is no longer supported.

Parameters

ResponseEvent $event:

File

src/EventSubscriber/RemoveXFrameOptionsSubscriber.php, line 27

Class

RemoveXFrameOptionsSubscriber

Namespace

Drupal\lti_tool_provider\EventSubscriber

Code

public function RemoveXFrameOptions($event) {
  if (Drupal::config('lti_tool_provider.settings')
    ->get('iframe')) {
    $session = $event
      ->getRequest()
      ->getSession();
    $context = $session
      ->get('lti_tool_provider_context');
    if (!empty($context) && Drupal::currentUser()
      ->isAuthenticated()) {
      $response = $event
        ->getResponse();
      $response->headers
        ->remove('X-Frame-Options');
    }
  }
}