You are here

download_file.module in DownloadFile 8

File

download_file.module
View source
<?php

use Drupal\Core\Link;
use Drupal\Core\Url;
function download_file_theme() {
  return [
    'direct_download_file_link' => [
      'variables' => [
        'url' => NULL,
        'link_text' => NULL,
        'attributes' => [],
        'file_id' => NULL,
      ],
    ],
  ];
}
function template_preprocess_direct_download_file_link(&$vars) {
  $url = URL::fromRoute('download_file.download_file_path', [
    'file_id' => $vars['file_id'],
  ]);
  $vars['link'] = Link::fromTextAndUrl($vars['link_text'], $url);
}