From 6a2f34697f72b09db3f88617388eaf8123d0b117 Mon Sep 17 00:00:00 2001 From: Brandon Kelly Date: Fri, 20 Jul 2018 05:43:35 -0700 Subject: [PATCH] Use registerTwigExtension() Fixes a bug where the plugin may cause Twig to be loaded before it should be, and another bug where the extension might not be available if the Template Mode ever changes from CP to Site, or vise-versa. --- src/Collections.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Collections.php b/src/Collections.php index ac1059b..cd3dd58 100644 --- a/src/Collections.php +++ b/src/Collections.php @@ -54,7 +54,7 @@ public function init() parent::init(); self::$plugin = $this; - Craft::$app->view->twig->addExtension(new CollectionsTwigExtension()); + Craft::$app->view->registerTwigExtension(new CollectionsTwigExtension()); Event::on( CraftVariable::class,