Add acutal response to BeforeTemplateRenderedEvent

Signed-off-by: Julius Härtl <jus@bitgrid.net>
pull/23012/head
Julius Härtl 4 years ago committed by Roeland Jago Douma
parent 54abcbc2aa
commit 8ab2422b6c
No known key found for this signature in database
GPG Key ID: F941078878347C0C
  1. 2
      lib/private/AppFramework/Middleware/AdditionalScriptsMiddleware.php
  2. 13
      lib/public/AppFramework/Http/Events/BeforeTemplateRenderedEvent.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;

@ -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;
}
}

Loading…
Cancel
Save