settings_tray.api.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * @file
  4. * Documentation for Settings Tray API.
  5. */
  6. /**
  7. * @defgroup settings_tray Settings Tray API
  8. * @{
  9. * Settings Tray API
  10. *
  11. * @section sec_overview Overview and terminology
  12. *
  13. * The Settings Tray module allows blocks to be configured in a sidebar form
  14. * without leaving the page. For example:
  15. *
  16. * - For every block, one can configure whether to display the block title or
  17. * not, and optionally override it (block configuration).
  18. * - For menu blocks, one can configure which menu levels to display (block
  19. * configuration) but also the menu itself (menu configuration).
  20. * - For the site branding block, one can change which branding elements to
  21. * display (block configuration), but also the site name and slogan (simple
  22. * configuration).
  23. *
  24. * Block visibility conditions are not included the sidebar form.
  25. *
  26. * @section sec_api The API: the form in the Settings Tray
  27. *
  28. * By default, the Settings Tray shows any block's built-in form in the
  29. * off-canvas dialog.
  30. *
  31. * @see core/misc/dialog/off-canvas.es6.js
  32. *
  33. * However, many blocks would benefit from a tailored form which either:
  34. * - limits the form items displayed in the Settings Tray to only items that
  35. * affect the content of the rendered block
  36. * - adds additional form items to edit configuration that is rendered by the
  37. * block. See \Drupal\settings_tray\Form\SystemBrandingOffCanvasForm which
  38. * adds site name and slogan configuration.
  39. *
  40. * These can be used to provide a better experience, so that the Settings Tray
  41. * only displays what the user will expect to change when editing the block.
  42. *
  43. * Each block plugin can specify which form to use in the Settings Tray dialog
  44. * in its plugin annotation:
  45. * @code
  46. * forms = {
  47. * "settings_tray" = "\Drupal\some_module\Form\MyBlockOffCanvasForm",
  48. * },
  49. * @endcode
  50. *
  51. * In some cases, a block's content is not configurable (for example, the title,
  52. * main content, and help blocks). Such blocks can opt out of providing a
  53. * settings_tray form:
  54. * @code
  55. * forms = {
  56. * "settings_tray" = FALSE,
  57. * },
  58. * @endcode
  59. *
  60. * Finally, blocks that do not specify a settings_tray form using the annotation
  61. * above will automatically have it set to their plugin class. For example, the
  62. * "Powered by Drupal" block plugin
  63. * (\Drupal\system\Plugin\Block\SystemPoweredByBlock) automatically gets this
  64. * added to its annotation:
  65. * @code
  66. * forms = {
  67. * "settings_tray" = "\Drupal\system\Plugin\Block\SystemPoweredByBlock",
  68. * },
  69. * @endcode
  70. *
  71. * Therefore, the entire Settings Tray API is just this annotation: it controls
  72. * what the Settings Tray does for a given block.
  73. *
  74. * @see settings_tray_block_alter()
  75. * @see \Drupal\Tests\settings_tray\Functional\SettingsTrayBlockTest::testPossibleAnnotations()
  76. *
  77. * @}
  78. */