From 8ab2422b6c34e5b0b6d1756cbadbb01899019456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 23 Sep 2020 08:43:36 +0200 Subject: [PATCH] Add acutal response to BeforeTemplateRenderedEvent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .../Middleware/AdditionalScriptsMiddleware.php | 2 +- .../Http/Events/BeforeTemplateRenderedEvent.php | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/private/AppFramework/Middleware/AdditionalScriptsMiddleware.php b/lib/private/AppFramework/Middleware/AdditionalScriptsMiddleware.php index 6c65ee8b2c..28f322f42b 100644 --- a/lib/private/AppFramework/Middleware/AdditionalScriptsMiddleware.php +++ b/lib/private/AppFramework/Middleware/AdditionalScriptsMiddleware.php @@ -71,7 +71,7 @@ class AdditionalScriptsMiddleware extends Middleware { $isLoggedIn = false; } - $this->dispatcher->dispatchTyped(new BeforeTemplateRenderedEvent($isLoggedIn)); + $this->dispatcher->dispatchTyped(new BeforeTemplateRenderedEvent($isLoggedIn, $response)); } return $response; diff --git a/lib/public/AppFramework/Http/Events/BeforeTemplateRenderedEvent.php b/lib/public/AppFramework/Http/Events/BeforeTemplateRenderedEvent.php index 3d48e9a269..b96b86abd5 100644 --- a/lib/public/AppFramework/Http/Events/BeforeTemplateRenderedEvent.php +++ b/lib/public/AppFramework/Http/Events/BeforeTemplateRenderedEvent.php @@ -27,6 +27,7 @@ declare(strict_types=1); namespace OCP\AppFramework\Http\Events; +use OCP\AppFramework\Http\TemplateResponse; use OCP\EventDispatcher\Event; /** @@ -38,14 +39,17 @@ use OCP\EventDispatcher\Event; class BeforeTemplateRenderedEvent extends Event { /** @var bool */ private $loggedIn; + /** @var TemplateResponse */ + private $response; /** * @since 20.0.0 */ - public function __construct(bool $loggedIn) { + public function __construct(bool $loggedIn, TemplateResponse $response) { parent::__construct(); $this->loggedIn = $loggedIn; + $this->response = $response; } /** @@ -54,4 +58,11 @@ class BeforeTemplateRenderedEvent extends Event { public function isLoggedIn(): bool { return $this->loggedIn; } + + /** + * @since 20.0.0 + */ + public function getResponse(): TemplateResponse { + return $this->response; + } }