You are here

class WebformShareEventSubscriber in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_share/src/EventSubscriber/WebformShareEventSubscriber.php \Drupal\webform_share\EventSubscriber\WebformShareEventSubscriber

Event subscriber to allow webform to be shared via an iframe.

Hierarchy

  • class \Drupal\webform_share\EventSubscriber\WebformShareEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of WebformShareEventSubscriber

1 string reference to 'WebformShareEventSubscriber'
webform_share.services.yml in modules/webform_share/webform_share.services.yml
modules/webform_share/webform_share.services.yml
1 service uses WebformShareEventSubscriber
webform_share.event_subscriber in modules/webform_share/webform_share.services.yml
Drupal\webform_share\EventSubscriber\WebformShareEventSubscriber

File

modules/webform_share/src/EventSubscriber/WebformShareEventSubscriber.php, line 14

Namespace

Drupal\webform_share\EventSubscriber
View source
class WebformShareEventSubscriber implements EventSubscriberInterface {

  /**
   * The current route match.
   *
   * @var \Drupal\Core\Routing\RouteMatchInterface
   */
  protected $routeMatch;

  /**
   * Constructs a WebformShareEventSubscriber object.
   *
   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
   *   The current route match.
   */
  public function __construct(RouteMatchInterface $route_match) {
    $this->routeMatch = $route_match;
  }

  /**
   * Remove 'X-Frame-Options' from the response header for shared webforms.
   *
   * @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
   *   The response event.
   */
  public function onResponse(FilterResponseEvent $event) {
    if (!WebformShareHelper::isPage($this->routeMatch)) {
      return;
    }
    $response = $event
      ->getResponse();
    $response->headers
      ->remove('X-Frame-Options');
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[KernelEvents::RESPONSE] = [
      'onResponse',
    ];
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
WebformShareEventSubscriber::$routeMatch protected property The current route match.
WebformShareEventSubscriber::getSubscribedEvents public static function
WebformShareEventSubscriber::onResponse public function Remove 'X-Frame-Options' from the response header for shared webforms.
WebformShareEventSubscriber::__construct public function Constructs a WebformShareEventSubscriber object.