[TWIG] Add extension to check if Firefox is being used

This commit is contained in:
2021-09-07 15:20:28 +01:00
committed by Hugo Sales
parent 0e50f0692e
commit ddd2ffe26a
3 changed files with 12 additions and 3 deletions

View File

@@ -116,6 +116,12 @@ class Runtime implements RuntimeExtensionInterface, EventSubscriberInterface
return $twig->render('@public_path/assets/icons/' . $icon_name . '.svg.twig', ['iconClass' => $icon_css_class]);
}
public function isFirefox(): bool
{
$re = '/.*(?i)\bfirefox\b.*/m';
return preg_match(pattern: $re, subject: $this->request->headers->get('User-Agent')) === 1;
}
// ----------------------------------------------------------
/**