class ResponseSubscriber in Analytics 8
Analytics ResponseSubscriber.
Hierarchy
- class \Drupal\analytics\EventSubscriber\ResponseSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ResponseSubscriber
1 string reference to 'ResponseSubscriber'
1 service uses ResponseSubscriber
File
- src/
EventSubscriber/ ResponseSubscriber.php, line 13
Namespace
Drupal\analytics\EventSubscriberView source
class ResponseSubscriber implements EventSubscriberInterface {
/**
* The analytics module configuration.
*
* @var \Drupal\Core\Config\ImmutableConfig
*/
protected $config;
/**
* Constructs a new ResponseSubscriber.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config
* The configuration factory.
*/
public function __construct(ConfigFactoryInterface $config) {
$this->config = $config
->get('analytics.settings');
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
KernelEvents::RESPONSE => [
'onKernelResponse',
],
];
}
/**
* Respond to the kernel response event.
*
* @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
* The event.
*/
public function onKernelResponse(FilterResponseEvent $event) {
if (!$event
->isMasterRequest()) {
return;
}
// Adds "Permissions-Policy: interest-cohort=()" header to disable FLoC.
if ($this->config
->get('privacy.disable_floc')) {
$event
->getResponse()->headers
->set('Permissions-Policy', 'interest-cohort=()');
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ResponseSubscriber:: |
protected | property | The analytics module configuration. | |
ResponseSubscriber:: |
public static | function | ||
ResponseSubscriber:: |
public | function | Respond to the kernel response event. | |
ResponseSubscriber:: |
public | function | Constructs a new ResponseSubscriber. |