diff --git a/core/modules/help/src/Annotation/HelpSection.php b/core/modules/help/src/Annotation/HelpSection.php index f890d79..d43156d 100644 --- a/core/modules/help/src/Annotation/HelpSection.php +++ b/core/modules/help/src/Annotation/HelpSection.php @@ -34,13 +34,13 @@ class HelpSection extends Plugin { public $id; /** - * The header of the help page section. + * The text to use as the title of the help page section. * * @var \Drupal\Core\Annotation\Translation * * @ingroup plugin_translatable */ - public $header; + public $title; /** * The description of the help page section. diff --git a/core/modules/help/src/Controller/HelpController.php b/core/modules/help/src/Controller/HelpController.php index a80afd2..9741c8c 100644 --- a/core/modules/help/src/Controller/HelpController.php +++ b/core/modules/help/src/Controller/HelpController.php @@ -81,17 +81,17 @@ public function helpMain() { continue; } - // Generate the links, and include the section. + // Add the section to the page. + /** @var \Drupal\help\HelpSectionPluginInterface $plugin */ + $plugin = $this->helpManager->createInstance($plugin_id); $this_output = [ '#theme' => 'help_section', - '#title' => $plugin_definition['header'], - '#description' => $plugin_definition['description'], + '#title' => $plugin->getTitle(), + '#description' => $plugin->getDescription(), '#empty' => $this->t('There is currently nothing in this section'), '#links' => [], ]; - /** @var \Drupal\help\HelpSectionPluginInterface $plugin */ - $plugin = $this->helpManager->createInstance($plugin_id); $links = $plugin->listTopics(); if (is_array($links) && count($links)) { $this_output['#links'] = $links; diff --git a/core/modules/help/src/HelpSectionPluginInterface.php b/core/modules/help/src/HelpSectionPluginInterface.php index 44df116..49bc463 100644 --- a/core/modules/help/src/HelpSectionPluginInterface.php +++ b/core/modules/help/src/HelpSectionPluginInterface.php @@ -22,6 +22,25 @@ */ interface HelpSectionPluginInterface extends PluginInspectionInterface, CacheableDependencyInterface { + + /** + * Returns the title of the help section. + * + * @return string + * The title text, which could be a plain string or an object that can be + * cast to a string. + */ + public function getTitle(); + + /** + * Returns the description text for the help section. + * + * @return string + * The description text, which could be a plain string or an object that + * can be cast to a string. + */ + public function getDescription(); + /** * Returns a list of topics to show in the help section. * diff --git a/core/modules/help/src/Plugin/HelpSection/HelpSectionPluginBase.php b/core/modules/help/src/Plugin/HelpSection/HelpSectionPluginBase.php index 0d81eab..c593473 100644 --- a/core/modules/help/src/Plugin/HelpSection/HelpSectionPluginBase.php +++ b/core/modules/help/src/Plugin/HelpSection/HelpSectionPluginBase.php @@ -22,4 +22,18 @@ use UnchangingCacheableDependencyTrait; + /** + * {@inheritdoc} + */ + public function getTitle() { + return $this->getPluginDefinition()['title']; + } + + /** + * {@inheritdoc} + */ + public function getDescription() { + return $this->getPluginDefinition()['description']; + } + } diff --git a/core/modules/help/src/Plugin/HelpSection/HookHelpSection.php b/core/modules/help/src/Plugin/HelpSection/HookHelpSection.php index 500aa77..e4cf4eb 100644 --- a/core/modules/help/src/Plugin/HelpSection/HookHelpSection.php +++ b/core/modules/help/src/Plugin/HelpSection/HookHelpSection.php @@ -17,7 +17,7 @@ * * @HelpSection( * id = "hook_help", - * header = @Translation("Module overviews"), + * title = @Translation("Module overviews"), * description = @Translation("Module overviews are provided by modules. Overviews available for your installed modules:"), * ) */ diff --git a/core/modules/tour/src/Plugin/HelpSection/TourHelpSection.php b/core/modules/tour/src/Plugin/HelpSection/TourHelpSection.php index 853d4d1..49c5da2 100644 --- a/core/modules/tour/src/Plugin/HelpSection/TourHelpSection.php +++ b/core/modules/tour/src/Plugin/HelpSection/TourHelpSection.php @@ -19,7 +19,7 @@ * * @HelpSection( * id = "tour", - * header = @Translation("Tours"), + * title = @Translation("Tours"), * description = @Translation("Tours guide you through workflows or explain concepts on various user interface pages. The tours with links in this list are on user interface landing pages; the tours without links will show on individual pages (such as when editing a View using the Views UI module). Available tours:"), * permission = "access tour" * ) @@ -68,10 +68,10 @@ public static function create(ContainerInterface $container, array $configuratio public function getCacheMaxAge() { // The calculation of which URL (if any) gets put on which tour depends // on a route access check. This can have a lot of inputs, including user - // permissions and other factors. Unfortunately, we don't have a way to - // get cachability metadata for each of these factors, so the only way - // to ensure that inapplicable information is not used is to forbid - // caching completely. + // permissions and other factors. Rather than doing a complicated + // accounting of the cache metadata for all of these possible factors, set + // the max age of the cache to zero to prevent using incorrect cached + // information. return 0; }