You are here

public function Html::buildHeader in Site Audit 8.3

Build the header of the page.

1 call to Html::buildHeader()
Html::__construct in src/Renderer/Html.php
@inherit

File

src/Renderer/Html.php, line 71

Class

Html

Namespace

Drupal\site_audit\Renderer

Code

public function buildHeader() {
  $this->build = [
    // '#type' => 'page',.
    'container' => [
      '#type' => 'html_tag',
      '#tag' => 'div',
      '#attributes' => [
        'class' => 'container',
      ],
      'page_header' => [
        '#type' => 'html_tag',
        '#tag' => 'h2',
        '#value' => $this
          ->t('<a href="@site-audit-uri">Site Audit</a> report for @site', [
          '@site-audit-uri' => 'https://drupal.org/project/site_audit',
          '@site' => $this->options['uri'],
        ]),
        '#attributes' => [
          'id' => 'page-header',
        ],
        'br' => [
          '#type' => 'html_tag',
          '#tag' => 'br',
        ],
        'sub_head' => [
          '#type' => 'html_tag',
          '#tag' => 'small',
          '#value' => $this
            ->t('Generated on @date_time', [
            '@date_time' => \Drupal::service('date.formatter')
              ->format(\Drupal::time()
              ->getRequestTime()),
          ]),
        ],
      ],
    ],
  ];
  if (is_array($this->report)) {

    // There are multiple reports.
    $this->build['container']['summary'] = [
      '#type' => 'html_tag',
      '#tag' => 'div',
      '#attributes' => [
        'id' => 'summary',
      ],
    ];
    $this->build['container']['summary']['title'] = [
      '#type' => 'html_tag',
      '#tag' => 'h2',
      '#value' => $this
        ->t('Summary'),
    ];
    $this->build['container']['summary']['links'] = [
      '#type' => 'html_tag',
      '#tag' => 'p',
    ];
    foreach ($this->report as $report) {
      $this->build['container']['summary']['links'][$report
        ->getPluginId()] = [
        '#type' => 'html_tag',
        '#tag' => 'a',
        '#value' => $report
          ->getLabel() . ' (' . $report
          ->getPercent() . '%)',
        '#attributes' => [
          'href' => '#' . $report
            ->getPluginId(),
          'class' => $this
            ->getPercentCssClass($report
            ->getPercent()),
        ],
      ];
    }
  }
}