BareHtmlPageRendererInterface.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace Drupal\Core\Render;
  3. /**
  4. * Bare HTML page renderer.
  5. *
  6. * By "bare HTML page", we mean that the following hooks that allow for "normal"
  7. * pages are not invoked:
  8. * - hook_page_attachments()
  9. * - hook_page_attachments_alter()
  10. * - hook_page_top()
  11. * - hook_page_bottom()
  12. *
  13. * Examples of bare HTML pages are:
  14. * - install.php
  15. * - update.php
  16. * - authorize.php
  17. * - maintenance mode
  18. * - exception handlers
  19. *
  20. * i.e. use this when rendering HTML pages in limited environments. Otherwise,
  21. * use a @code _controller @endcode route, and return a render array.
  22. * This will cause a main content renderer
  23. * (\Drupal\Core\Render\MainContent\MainContentRendererInterface) to be
  24. * used, and in case of a HTML request that will be
  25. * \Drupal\Core\Render\MainContent\HtmlRenderer.
  26. *
  27. * In fact, this is not only *typically* used in a limited environment, it even
  28. * *must* be used in a limited environment: when using the bare HTML page
  29. * renderer, use as little state/additional services as possible, because the
  30. * same safeguards aren't present (precisely because this is intended to be used
  31. * in a limited environment).
  32. *
  33. * Currently, there are two types of bare pages available:
  34. * - Install (hook_preprocess_install_page(), install-page.html.twig).
  35. * - Maintenance (hook_preprocess_maintenance_page(),
  36. * maintenance-page.html.twig).
  37. *
  38. * @see \Drupal\Core\Render\MainContent\HtmlRenderer
  39. */
  40. interface BareHtmlPageRendererInterface {
  41. /**
  42. * Renders a bare page.
  43. *
  44. * @param array $content
  45. * The main content to render in the 'content' region.
  46. * @param string $title
  47. * The title for this maintenance page.
  48. * @param string $page_theme_property
  49. * The #theme property to set on #type 'page'.
  50. * @param array $page_additions
  51. * Additional regions to add to the page. May also be used to pass the
  52. * #show_messages property for #type 'page'.
  53. *
  54. * @return \Drupal\Core\Render\HtmlResponse
  55. * The rendered HTML response, ready to be sent.
  56. */
  57. public function renderBarePage(array $content, $title, $page_theme_property, array $page_additions = []);
  58. }