You are here

public function FastlySettingsForm::purgeAll in Fastly 8.3

Purge all.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

\Drupal\Core\Ajax\AjaxResponse AjaxResponse.

File

src/Form/FastlySettingsForm.php, line 393

Class

FastlySettingsForm
Class FastlySettingsForm Defines a form to configure module settings.

Namespace

Drupal\fastly\Form

Code

public function purgeAll(array $form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  $purge = $this->api
    ->purgeAll(FALSE);
  if (!$purge) {
    $message = $this
      ->t("Something went wrong while purging / invalidating content. Please, check logs for more info.");
  }
  else {
    $message = $this
      ->t("Entire service purged successfully.");
  }
  $response
    ->addCommand(new HtmlCommand('.purge-all-message', $message));
  return $response;
}