[TWIG] Add extension to check if Firefox is being used
This commit is contained in:
parent
0e50f0692e
commit
ddd2ffe26a
@ -58,6 +58,7 @@ class Extension extends AbstractExtension
|
||||
new TwigFunction('handle_event', [Runtime::class, 'handleEvent']),
|
||||
new TwigFunction('config', [Runtime::class, 'getConfig']),
|
||||
new TwigFunction('icon', [Runtime::class, 'embedSvgIcon'], ['needs_environment' => true]),
|
||||
new TwigFunction('is_firefox', [Runtime::class, 'isFirefox']),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
@ -37,9 +37,11 @@
|
||||
<br>
|
||||
|
||||
<p>
|
||||
<em><b>Firefox based browser: </b> <kbd>Alt</kbd> + <kbd>Shift</kbd> + "access key"</em>
|
||||
<br>
|
||||
<em><b>Others: </b> <kbd>Alt</kbd> + "access key"</em>
|
||||
{% if is_firefox() == true %}
|
||||
<em><kbd>Alt</kbd> + <kbd>Shift</kbd> + "access key"</em>
|
||||
{% else %}
|
||||
<em><kbd>Alt</kbd> + "access key"</em>
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
|
Loading…
Reference in New Issue
Block a user