class WebformShareEventSubscriber in Webform 6.x
Same name and namespace in other branches
- 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
File
- modules/
webform_share/ src/ EventSubscriber/ WebformShareEventSubscriber.php, line 14
Namespace
Drupal\webform_share\EventSubscriberView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
WebformShareEventSubscriber:: |
protected | property | The current route match. | |
WebformShareEventSubscriber:: |
public static | function | ||
WebformShareEventSubscriber:: |
public | function | Remove 'X-Frame-Options' from the response header for shared webforms. | |
WebformShareEventSubscriber:: |
public | function | Constructs a WebformShareEventSubscriber object. |