From 5e076b70b79ddf7bc6e07122b4646961db280be5 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 15 Nov 2024 16:41:11 +0100 Subject: FunctionParser: No static property/methods anymore Problem: When creating a new "FunctionParser" object, it should not know the previously registered content functions which were saved in a static class property and registered via static class method. If one creates a new "FunctionParser" object, one would expect that the array of registered content functions in that object is empty. Changes: - Make static property "functions" non-static - Make static method "register" non-static - Add new method "registerFromArray" --- core/functions.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'core/functions.php') diff --git a/core/functions.php b/core/functions.php index d4337a4..9202bad 100644 --- a/core/functions.php +++ b/core/functions.php @@ -101,6 +101,10 @@ function generateItemTemplateData(EntityInterface $Entity): array { $FunctionParser = new FunctionParser; $MarkdownParser = new MarkdownParser; + $FunctionParser->registerFromArray( + Application::getContentFunctions() + ); + $attribute = $Entity->getAll(['password']); $attribute = array_change_key_case($attribute, CASE_UPPER); @@ -159,7 +163,11 @@ function generateCategoryDataTree(array $category_data, $root = 0): array { function parseEntityContent(EntityInterface $Entity): string { $text = $Entity->get('body'); - $FunctionParser = new FunctionParser(); + $FunctionParser = new FunctionParser; + $FunctionParser->registerFromArray( + Application::getContentFunctions() + ); + $text = $FunctionParser->transform($text); if(Application::get('WRAP_EMOTICONS')) { -- cgit v1.2.3