BeforeTemplateRenderedEvent.php 975 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\AppFramework\Http\Events;
  8. use OCP\AppFramework\Http\TemplateResponse;
  9. use OCP\EventDispatcher\Event;
  10. /**
  11. * Emitted before the rendering step of each TemplateResponse. The event holds a
  12. * flag that specifies if an user is logged in.
  13. *
  14. * @since 20.0.0
  15. */
  16. class BeforeTemplateRenderedEvent extends Event {
  17. /** @var bool */
  18. private $loggedIn;
  19. /** @var TemplateResponse */
  20. private $response;
  21. /**
  22. * @since 20.0.0
  23. */
  24. public function __construct(bool $loggedIn, TemplateResponse $response) {
  25. parent::__construct();
  26. $this->loggedIn = $loggedIn;
  27. $this->response = $response;
  28. }
  29. /**
  30. * @since 20.0.0
  31. */
  32. public function isLoggedIn(): bool {
  33. return $this->loggedIn;
  34. }
  35. /**
  36. * @since 20.0.0
  37. */
  38. public function getResponse(): TemplateResponse {
  39. return $this->response;
  40. }
  41. }