You are here

public function StaticGeneratorForm::finishCallback in Tome 8

Batch finished callback after all paths and assets have been exported.

Parameters

bool $success: Whether or not the batch was successful.

mixed $results: Batch results set with context.

File

modules/tome_static/src/Form/StaticGeneratorForm.php, line 219

Class

StaticGeneratorForm
Contains a form for initializing a static build.

Namespace

Drupal\tome_static\Form

Code

public function finishCallback($success, $results) {
  $this->state
    ->set(StaticGeneratorInterface::STATE_KEY_BUILDING, FALSE);
  $this
    ->messenger()
    ->deleteAll();
  if (!$success) {
    $this
      ->messenger()
      ->addError($this
      ->t('Static build failed - consult the error log for more details.'));
    return;
  }
  if (!empty($results['errors'])) {
    foreach ($results['errors'] as $error) {
      $this
        ->messenger()
        ->addError($error);
    }
  }
  $this
    ->messenger()
    ->addStatus($this
    ->t('Static build complete! To download the build, <a href=":download">click here.</a>', [
    '@dir' => $this->static
      ->getStaticDirectory(),
    ':download' => Url::fromRoute('tome_static.download_page')
      ->toString(),
  ]));
}