annotate core/modules/help/help.api.php @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children 12f9dff5fda9
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /**
Chris@0 4 * @file
Chris@0 5 * Hooks for the Help system.
Chris@0 6 */
Chris@0 7
Chris@0 8 /**
Chris@0 9 * @addtogroup hooks
Chris@0 10 * @{
Chris@0 11 */
Chris@0 12
Chris@0 13 /**
Chris@0 14 * Provide online user help.
Chris@0 15 *
Chris@0 16 * By implementing hook_help(), a module can make documentation available to
Chris@0 17 * the user for the module as a whole, or for specific pages. Help for
Chris@0 18 * developers should usually be provided via function header comments in the
Chris@0 19 * code, or in special API example files.
Chris@0 20 *
Chris@0 21 * The page-specific help information provided by this hook appears in the
Chris@0 22 * Help block (provided by the core Help module), if the block is displayed on
Chris@0 23 * that page. The module overview help information is displayed by the Help
Chris@0 24 * module. It can be accessed from the page at /admin/help or from the Extend
Chris@0 25 * page. If a module implements hook_help() the help system expects module
Chris@0 26 * overview help to be provided.
Chris@0 27 *
Chris@0 28 * For detailed usage examples of:
Chris@0 29 * - Module overview help, see content_translation_help(). Module overview
Chris@0 30 * help should follow
Chris@0 31 * @link https://www.drupal.org/node/632280 the standard help template. @endlink
Chris@0 32 * - Page-specific help using only routes, see book_help().
Chris@0 33 * - Page-specific help using routes and $request, see block_help().
Chris@0 34 *
Chris@0 35 * @param string $route_name
Chris@0 36 * For page-specific help, use the route name as identified in the
Chris@0 37 * module's routing.yml file. For module overview help, the route name
Chris@0 38 * will be in the form of "help.page.$modulename".
Chris@0 39 * @param Drupal\Core\Routing\RouteMatchInterface $route_match
Chris@0 40 * The current route match. This can be used to generate different help
Chris@0 41 * output for different pages that share the same route.
Chris@0 42 *
Chris@0 43 * @return string|array
Chris@0 44 * A render array, localized string, or object that can be rendered into
Chris@0 45 * a string, containing the help text.
Chris@0 46 */
Chris@0 47 function hook_help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match) {
Chris@0 48 switch ($route_name) {
Chris@0 49 // Main module help for the block module.
Chris@0 50 case 'help.page.block':
Chris@0 51 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>';
Chris@0 52
Chris@0 53 // Help for another path in the block module.
Chris@0 54 case 'block.admin_display':
Chris@0 55 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>';
Chris@0 56 }
Chris@0 57 }
Chris@0 58
Chris@0 59 /**
Chris@0 60 * Perform alterations on help page section plugin definitions.
Chris@0 61 *
Chris@0 62 * Sections for the page at /admin/help are provided by plugins. This hook
Chris@0 63 * allows modules to alter the plugin definitions.
Chris@0 64 *
Chris@0 65 * @param array $info
Chris@0 66 * Array of plugin information exposed by hook page section plugins, altered
Chris@0 67 * by reference.
Chris@0 68 *
Chris@0 69 * @see \Drupal\help\HelpSectionPluginInterface
Chris@0 70 * @see \Drupal\help\Annotation\HelpSection
Chris@0 71 * @see \Drupal\help\HelpSectionManager
Chris@0 72 */
Chris@0 73 function hook_help_section_info_alter(&$info) {
Chris@0 74 // Alter the header for the module overviews section.
Chris@0 75 $info['hook_help']['header'] = t('Overviews of modules');
Chris@0 76 }
Chris@0 77
Chris@0 78 /**
Chris@0 79 * @} End of "addtogroup hooks".
Chris@0 80 */