You are here

class RemoveXFrameOptionsSubscriber in LTI Tool Provider 8

Same name and namespace in other branches
  1. 2.x src/EventSubscriber/RemoveXFrameOptionsSubscriber.php \Drupal\lti_tool_provider\EventSubscriber\RemoveXFrameOptionsSubscriber

Hierarchy

  • class \Drupal\lti_tool_provider\EventSubscriber\RemoveXFrameOptionsSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of RemoveXFrameOptionsSubscriber

1 string reference to 'RemoveXFrameOptionsSubscriber'
lti_tool_provider.services.yml in ./lti_tool_provider.services.yml
lti_tool_provider.services.yml
1 service uses RemoveXFrameOptionsSubscriber
lti_tool_provider.xframe.event_subscriber in ./lti_tool_provider.services.yml
Drupal\lti_tool_provider\EventSubscriber\RemoveXFrameOptionsSubscriber

File

src/EventSubscriber/RemoveXFrameOptionsSubscriber.php, line 10

Namespace

Drupal\lti_tool_provider\EventSubscriber
View source
class RemoveXFrameOptionsSubscriber implements EventSubscriberInterface {

  /**
   * @param ResponseEvent $event
   *
   * @todo Only add ResponseEvent typing to $event once D8 is no longer supported.
   */
  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');
      }
    }
  }

  /**
   * @return array|mixed
   */
  public static function getSubscribedEvents() : array {
    $events[KernelEvents::RESPONSE][] = [
      'RemoveXFrameOptions',
      -10,
    ];
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RemoveXFrameOptionsSubscriber::getSubscribedEvents public static function
RemoveXFrameOptionsSubscriber::RemoveXFrameOptions public function @todo Only add ResponseEvent typing to $event once D8 is no longer supported.