From d8eaa2ce1a6bfaa36728b5c737962779fe35fc7a Mon Sep 17 00:00:00 2001 From: trendschau Date: Mon, 9 Sep 2024 20:52:01 +0200 Subject: [PATCH] V 2.9.0 Add event onTwigGlobalsLoaded --- .../ControllerApiSystemExtensions.php | 4 +++- .../typemill/Events/OnTwigGlobalsLoaded.php | 14 ++++++++++++ system/typemill/Models/License.php | 4 ++-- .../typemill/author/js/vue-blox-components.js | 1 + system/typemill/author/js/vue-blox.js | 2 +- system/typemill/system.php | 22 ++++++++++++++----- 6 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 system/typemill/Events/OnTwigGlobalsLoaded.php diff --git a/system/typemill/Controllers/ControllerApiSystemExtensions.php b/system/typemill/Controllers/ControllerApiSystemExtensions.php index 7343e1c..40cb4b2 100644 --- a/system/typemill/Controllers/ControllerApiSystemExtensions.php +++ b/system/typemill/Controllers/ControllerApiSystemExtensions.php @@ -57,7 +57,9 @@ class ControllerApiSystemExtensions extends Controller $license = new License(); $urlinfo = $this->c->get('urlinfo'); - if(!$license->checkIfTest($urlinfo)) + $test = $license->checkIfTest($urlinfo); + + if($license->checkIfTest($urlinfo) !== true) { # checks if license is valid and returns scope $licenseScope = $license->getLicenseScope($urlinfo); diff --git a/system/typemill/Events/OnTwigGlobalsLoaded.php b/system/typemill/Events/OnTwigGlobalsLoaded.php new file mode 100644 index 0000000..119c462 --- /dev/null +++ b/system/typemill/Events/OnTwigGlobalsLoaded.php @@ -0,0 +1,14 @@ + NULL, 'flash' => NULL, 'assets' => NULL]; +$TwigGlobals = $dispatcher->dispatch(new OnTwigGlobalsLoaded($TwigGlobals), 'onTwigGlobalsLoaded')->getData(); + +# echo '
';
+# print_r($TwigGlobals);
+# die();
+
 /****************************
 * OTHER CONTAINER ITEMS			*
 ****************************/
@@ -298,7 +306,7 @@ $container->set('assets', function() use ($assets){ return $assets; });
 * TWIG TO CONTAINER					*
 ****************************/
 
-$container->set('view', function() use ($settings, $urlinfo, $translations, $dispatcher) {
+$container->set('view', function() use ($settings, $TwigGlobals, $urlinfo, $translations, $dispatcher) {
 
 	$twig = Twig::create(
 		[
@@ -314,10 +322,12 @@ $container->set('view', function() use ($settings, $urlinfo, $translations, $dis
 			'autoescape' => false
 		]
 	);
-	
-	$twig->getEnvironment()->addGlobal('errors', NULL);
-	$twig->getEnvironment()->addGlobal('flash', NULL);
-	$twig->getEnvironment()->addGlobal('assets', NULL);
+
+	foreach($TwigGlobals as $name => $feature)
+	{
+#		echo $name . ';';
+		$twig->getEnvironment()->addGlobal($name, $feature);
+	}
 
 	# add extensions
 	$twig->addExtension(new DebugExtension());