ErrorController.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Core\Controller;
  8. use OCP\AppFramework\Http;
  9. use OCP\AppFramework\Http\Attribute\FrontpageRoute;
  10. use OCP\AppFramework\Http\Attribute\OpenAPI;
  11. use OCP\AppFramework\Http\TemplateResponse;
  12. #[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
  13. class ErrorController extends \OCP\AppFramework\Controller {
  14. /**
  15. * @PublicPage
  16. * @NoCSRFRequired
  17. */
  18. #[FrontpageRoute(verb: 'GET', url: 'error/403')]
  19. public function error403(): TemplateResponse {
  20. $response = new TemplateResponse(
  21. 'core',
  22. '403',
  23. [],
  24. 'error'
  25. );
  26. $response->setStatus(Http::STATUS_FORBIDDEN);
  27. return $response;
  28. }
  29. /**
  30. * @PublicPage
  31. * @NoCSRFRequired
  32. */
  33. #[FrontpageRoute(verb: 'GET', url: 'error/404')]
  34. public function error404(): TemplateResponse {
  35. $response = new TemplateResponse(
  36. 'core',
  37. '404',
  38. [],
  39. 'error'
  40. );
  41. $response->setStatus(Http::STATUS_NOT_FOUND);
  42. return $response;
  43. }
  44. }