Unverified Commit 66f0925c authored by Alex Pott's avatar Alex Pott
Browse files

task: #3191278 Use plugin id to make help section headers HTML IDs

By: andypost
By: amber himes matz
By: tobiasb
By: rkoller
By: benjifisher
By: simohell
(cherry picked from commit 06c1f1b1)
parent 104b606a
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ public function helpMain() {
      $plugin = $this->helpManager->createInstance($plugin_id);
      $this_output = [
        '#theme' => 'help_section',
        '#plugin_id' => $plugin_id,
        '#title' => $plugin->getTitle(),
        '#description' => $plugin->getDescription(),
        '#empty' => $this->t('There is currently nothing in this section.'),
+4 −1
Original line number Diff line number Diff line
@@ -84,7 +84,9 @@ public function help($route_name, RouteMatchInterface $route_match): string|arra
        return ['#markup' => $output];

      case 'help.help_topic':
        $help_home = Url::fromRoute('help.main')->toString();
        $help_home = Url::fromRoute('help.main')
          ->setOption('fragment', 'help-topics')
          ->toString();
        return '<p>' . $this->t('See the <a href=":help_page">Help page</a> for more topics.', [':help_page' => $help_home]) . '</p>';
    }
    return NULL;
@@ -98,6 +100,7 @@ public function theme($existing, $type, $theme, $path) : array {
    return [
      'help_section' => [
        'variables' => [
          'plugin_id' => NULL,
          'title' => NULL,
          'description' => NULL,
          'links' => NULL,
+2 −1
Original line number Diff line number Diff line
@@ -8,11 +8,12 @@
 * - description: The description text for the section.
 * - links: Links to display in the section.
 * - empty: Text to display if there are no links.
 * - plugin_id: The help section plugin ID.
 *
 * @ingroup themeable
 */
#}
<h2>{{ title }}</h2>
<h2 id="{{ plugin_id|clean_id }}">{{ title }}</h2>
<p>{{ description }}</p>
{% if links %}
  <ul>
+2 −2
Original line number Diff line number Diff line
@@ -89,11 +89,11 @@ public function testHelp(): void {
    $this->assertSession()->responseContains('For more information, refer to the help listed on this page or to the <a href="https://www.drupal.org/documentation">online documentation</a> and <a href="https://www.drupal.org/support">support</a> pages at <a href="https://www.drupal.org">drupal.org</a>.');

    // Verify that hook_help() section title and description appear.
    $this->assertSession()->responseContains('<h2>Module overviews</h2>');
    $this->assertSession()->responseContains('<h2 id="hook-help">Module overviews</h2>');
    $this->assertSession()->responseContains('<p>Module overviews are provided by modules. Overviews available for your installed modules:</p>');

    // Verify that an empty section is handled correctly.
    $this->assertSession()->responseContains('<h2>Empty section</h2>');
    $this->assertSession()->responseContains('<h2 id="empty-section">Empty section</h2>');
    $this->assertSession()->responseContains('<p>This description should appear.</p>');
    $this->assertSession()->pageTextContains('There is currently nothing in this section.');

+1 −1
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ public function testHelp(): void {

    // Verify that help topics text appears on admin/help, and cache tags.
    $this->drupalGet('admin/help');
    $session->responseContains('<h2>Topics</h2>');
    $session->responseContains('<h2 id="help-topics">Topics</h2>');
    $session->pageTextContains('Topics can be provided by modules or themes');
    $session->responseHeaderContains('X-Drupal-Cache-Tags', 'core.extension');

Loading