You are here

public function StaticDownloadController::build in Tome 8

Presents a user interface to download a static build.

1 string reference to 'StaticDownloadController::build'
tome_static.routing.yml in modules/tome_static/tome_static.routing.yml
modules/tome_static/tome_static.routing.yml

File

modules/tome_static/src/Controller/StaticDownloadController.php, line 62

Class

StaticDownloadController
Contains routes related to Tome Static.

Namespace

Drupal\tome_static\Controller

Code

public function build() {
  $build = [];
  $download_url = Url::fromRoute('tome_static.download');
  if ($download_url
    ->access()) {
    $build['description'] = [
      '#type' => 'markup',
      '#markup' => '<p>' . $this
        ->t('Download the latest static build of this site as a gzipped tar file.') . '</p>',
    ];
    $build['download'] = [
      '#type' => 'link',
      '#attributes' => [
        'class' => [
          'button',
        ],
      ],
      '#title' => $this
        ->t('Download'),
      '#url' => $download_url,
    ];
  }
  else {
    $build['description'] = [
      '#type' => 'markup',
      '#markup' => '<p>' . $this
        ->t('No static build available for download. <a href=":generate">Click here to generate one.</a>', [
        ':generate' => Url::fromRoute('tome_static.generate')
          ->toString(),
      ]) . '</p>',
    ];
  }
  return $build;
}