You are here

function forward_page_attachments in Forward 4.x

Same name and namespace in other branches
  1. 8.3 forward.module \forward_page_attachments()
  2. 8 forward.module \forward_page_attachments()
  3. 8.2 forward.module \forward_page_attachments()
  4. 4.0.x forward.module \forward_page_attachments()

Implements hook_page_attachments().

File

./forward.module, line 31
Allows forwarding of entities by email.

Code

function forward_page_attachments(array &$page) {
  if (\Drupal::routeMatch()
    ->getRouteName() == 'forward.form') {
    $settings = \Drupal::config('forward.settings')
      ->get();

    // Tell SEO to ignore this page on request.
    if ($settings['forward_form_noindex']) {
      $element = [
        '#type' => 'html_tag',
        '#tag' => 'meta',
        '#attributes' => [
          'name' => 'robots',
          'content' => 'noindex, nofollow',
        ],
      ];
      $page['#attached']['html_head'][] = [
        $element,
        'forward_meta_noindex',
      ];
    }
  }
}