From b6c171edda722676b2279f955dd3395714220ae5 Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Fri, 17 Jan 2025 14:07:59 +0100 Subject: [PATCH] Only register if FormatterRuntime does not exist --- src/Twig/NotificationCenterExtension.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Twig/NotificationCenterExtension.php b/src/Twig/NotificationCenterExtension.php index c6b09ae..7ccb737 100644 --- a/src/Twig/NotificationCenterExtension.php +++ b/src/Twig/NotificationCenterExtension.php @@ -4,6 +4,7 @@ namespace Terminal42\NotificationCenterBundle\Twig; +use Contao\CoreBundle\Twig\Runtime\FormatterRuntime; use Twig\Extension\AbstractExtension; use Twig\TwigFilter; use Twig\TwigFunction; @@ -19,6 +20,11 @@ public function getFunctions(): array public function getFilters(): array { + // This class only exists in Contao 5 and provides the format_bytes filter. + if (class_exists(FormatterRuntime::class)) { + return []; + } + return [ new TwigFilter( 'format_bytes',