Http4xxController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace Drupal\system\Controller;
  3. use Drupal\Core\Controller\ControllerBase;
  4. /**
  5. * Controller for default HTTP 4xx responses.
  6. */
  7. class Http4xxController extends ControllerBase {
  8. /**
  9. * The default 4xx error content.
  10. *
  11. * @return array
  12. * A render array containing the message to display for 4xx errors.
  13. */
  14. public function on4xx() {
  15. return [
  16. '#markup' => $this->t('A client error happened'),
  17. ];
  18. }
  19. /**
  20. * The default 401 content.
  21. *
  22. * @return array
  23. * A render array containing the message to display for 401 pages.
  24. */
  25. public function on401() {
  26. return [
  27. '#markup' => $this->t('Please log in to access this page.'),
  28. ];
  29. }
  30. /**
  31. * The default 403 content.
  32. *
  33. * @return array
  34. * A render array containing the message to display for 403 pages.
  35. */
  36. public function on403() {
  37. return [
  38. '#markup' => $this->t('You are not authorized to access this page.'),
  39. ];
  40. }
  41. /**
  42. * The default 404 content.
  43. *
  44. * @return array
  45. * A render array containing the message to display for 404 pages.
  46. */
  47. public function on404() {
  48. return [
  49. '#markup' => $this->t('The requested page could not be found.'),
  50. ];
  51. }
  52. }