You are here

function template_preprocess_forward in Forward 8

Same name and namespace in other branches
  1. 8.3 forward.module \template_preprocess_forward()
  2. 8.2 forward.module \template_preprocess_forward()
  3. 6 forward.module \template_preprocess_forward()
  4. 7.3 forward.module \template_preprocess_forward()
  5. 7 forward.module \template_preprocess_forward()
  6. 7.2 forward.module \template_preprocess_forward()
  7. 4.x forward.module \template_preprocess_forward()
  8. 4.0.x forward.module \template_preprocess_forward()

Implements template_preprocess_module().

File

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

Code

function template_preprocess_forward(&$variables) {

  // Site info
  $url = 'internal:' . \Drupal::config('system.site')
    ->get('page.front');
  $variables['site_url'] = Url::fromUri($url, [
    'absolute' => TRUE,
  ]);
  $variables['site_name'] = \Drupal::config('system.site')
    ->get('name');

  // Read more link; skipped for teasers since most teasers already include a link
  $variables['link'] = '';
  $entity = $variables['entity'];
  if ($entity
    ->access('view') && $variables['view_mode'] != 'teaser') {
    $variables['link'] = t('<a href="@entity-url">Read more about @entity-name</a>', array(
      '@entity-url' => $entity
        ->toUrl()
        ->toString(),
      '@entity-name' => $entity
        ->label(),
    ));
  }

  // Logo
  if (!empty($variables['settings']['forward_email_logo'])) {
    $url = 'base:' . $variables['settings']['forward_email_logo'];
    $url = Url::fromUri($url, [
      'absolute' => TRUE,
    ])
      ->toString();
  }
  else {
    $url = theme_get_setting('logo.url');
    if (!UrlHelper::isExternal($url)) {
      $url = Url::fromUri('base:/' . $url, [
        'absolute' => TRUE,
      ])
        ->toString();
    }
  }
  $variables['logo'] = [
    '#markup' => '<img src="' . $url . '" />',
  ];
}