Drupal investigation

help.api.php 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * @file
  4. * Hooks for the Help system.
  5. */
  6. /**
  7. * @addtogroup hooks
  8. * @{
  9. */
  10. /**
  11. * Provide online user help.
  12. *
  13. * By implementing hook_help(), a module can make documentation available to
  14. * the user for the module as a whole, or for specific pages. Help for
  15. * developers should usually be provided via function header comments in the
  16. * code, or in special API example files.
  17. *
  18. * The page-specific help information provided by this hook appears in the
  19. * Help block (provided by the core Help module), if the block is displayed on
  20. * that page. The module overview help information is displayed by the Help
  21. * module. It can be accessed from the page at /admin/help or from the Extend
  22. * page. If a module implements hook_help() the help system expects module
  23. * overview help to be provided.
  24. *
  25. * For detailed usage examples of:
  26. * - Module overview help, see content_translation_help(). Module overview
  27. * help should follow
  28. * @link https://www.drupal.org/node/632280 the standard help template. @endlink
  29. * - Page-specific help using only routes, see book_help().
  30. * - Page-specific help using routes and $request, see block_help().
  31. *
  32. * @param string $route_name
  33. * For page-specific help, use the route name as identified in the
  34. * module's routing.yml file. For module overview help, the route name
  35. * will be in the form of "help.page.$modulename".
  36. * @param Drupal\Core\Routing\RouteMatchInterface $route_match
  37. * The current route match. This can be used to generate different help
  38. * output for different pages that share the same route.
  39. *
  40. * @return string|array
  41. * A render array, localized string, or object that can be rendered into
  42. * a string, containing the help text.
  43. */
  44. function hook_help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match) {
  45. switch ($route_name) {
  46. // Main module help for the block module.
  47. case 'help.page.block':
  48. return '<p>' . t('Blocks are boxes of content rendered into an area, or region, of a web page. The default theme Bartik, for example, implements the regions "Sidebar first", "Sidebar second", "Featured", "Content", "Header", "Footer", etc., and a block may appear in any one of these areas. The <a href=":blocks">blocks administration page</a> provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions.', [':blocks' => \Drupal::url('block.admin_display')]) . '</p>';
  49. // Help for another path in the block module.
  50. case 'block.admin_display':
  51. return '<p>' . t('This page provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the <em>Save blocks</em> button at the bottom of the page.') . '</p>';
  52. }
  53. }
  54. /**
  55. * Perform alterations on help page section plugin definitions.
  56. *
  57. * Sections for the page at /admin/help are provided by plugins. This hook
  58. * allows modules to alter the plugin definitions.
  59. *
  60. * @param array $info
  61. * Array of plugin information exposed by hook page section plugins, altered
  62. * by reference.
  63. *
  64. * @see \Drupal\help\HelpSectionPluginInterface
  65. * @see \Drupal\help\Annotation\HelpSection
  66. * @see \Drupal\help\HelpSectionManager
  67. */
  68. function hook_help_section_info_alter(&$info) {
  69. // Alter the header for the module overviews section.
  70. $info['hook_help']['header'] = t('Overviews of modules');
  71. }
  72. /**
  73. * @} End of "addtogroup hooks".
  74. */