Skip to content

Commit

Permalink
Add error message if purge clear can't be performed.
Browse files Browse the repository at this point in the history
  • Loading branch information
kepol committed Jul 26, 2023
1 parent 45459b6 commit 3b8aec0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/quant_purger/src/Form/ConfigurationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,15 @@ public function submitFormClear(array &$form, FormStateInterface $form_state) {

if (!$form_state->getErrors()) {
\Drupal::service('quant_purger.registry')->clear();
$status = 'status';
$message = $this->t('Succesfully cleared the traffic registry.');
}
else {
$status = 'error';
$message = $this->t('Unable to clear the traffic registry due to form errors.');
}

$message = $this->t('Succesfully cleared the traffic registry');
$response->addCommand(new PrependCommand('#purgedialogform', '<div class="messages messages--status" style="margin-top: 1rem"><div class="message__content">' . $message . '</div></div>'));
$response->addCommand(new PrependCommand('#purgedialogform', '<div class="messages messages--' . $status . '" style="margin-top: 1rem"><div class="message__content">' . $message . '</div></div>'));

return $response;
}
Expand Down

0 comments on commit 3b8aec0

Please sign in to comment.