From 90c75e7f10f9a5ebb777649f1ef2b149ee7333b1 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms Date: Thu, 16 Jan 2025 15:00:42 +0000 Subject: post notifications VueAppWillRender and VueAppDidRender in StudipController::renderVueApp() as well and provide method that directly sets slots on a VueApp instance, fixes #5148 Closes #5148 Merge request studip/studip!3848 --- lib/classes/StudipController.php | 4 ++++ lib/classes/VueApp.php | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/classes/StudipController.php b/lib/classes/StudipController.php index b7c55fd..ec32f27 100644 --- a/lib/classes/StudipController.php +++ b/lib/classes/StudipController.php @@ -593,7 +593,11 @@ abstract class StudipController extends Trails\Controller */ public function render_vue_app(\Studip\VueApp $app): void { + \NotificationCenter::postNotification('VueAppWillRender', $app); + $this->render_template($app->getTemplate(), $this->layout); + + \NotificationCenter::postNotification('VueAppDidRender', $app); } diff --git a/lib/classes/VueApp.php b/lib/classes/VueApp.php index c26b011..910f503 100644 --- a/lib/classes/VueApp.php +++ b/lib/classes/VueApp.php @@ -83,6 +83,15 @@ final class VueApp implements Stringable } /** + * Set the content of a slot. + */ + public function setSlot(string $name, string|Template $content): VueApp + { + $this->slots[$name] = $content instanceof Template ? $content->render() : $content; + return $this; + } + + /** * Add a slot with the given name * * If you pass a flexi template as the content, it will be rendered. -- cgit v1.0