*/ class AddFeaturePolicyListener implements IEventListener { public function __construct( private IRequest $request, private AppConfig $config, ) { } #[\Override] public function handle(Event $event): void { if (!$event instanceof AddFeaturePolicyEvent) { return; } if (!$this->isPageLoad()) { return; } $policy = new FeaturePolicy(); foreach ($this->config->getDomainList() as $url) { $policy->addAllowedFullScreenDomain($url); } $event->addPolicy($policy); } private function isPageLoad(): bool { $scriptNameParts = explode('/', $this->request->getScriptName()); return end($scriptNameParts) === 'index.php'; } }