You are here

public static function ProcessQueueForm::finishBatch in Field Encryption 3.0.x

Finish batch encryption updates of fields.

Parameters

bool $success: A boolean indicating whether the batch has completed successfully.

array $results: The value set in $context['results'] by callback_batch_operation().

File

src/Form/ProcessQueueForm.php, line 166

Class

ProcessQueueForm
Form builder for the field_encrypt process queue form.

Namespace

Drupal\field_encrypt\Form

Code

public static function finishBatch($success, array $results) {

  // The 'success' parameter means no fatal PHP errors were detected. All
  // other error management should be handled using 'results'.
  if (!empty($results['errors'])) {
    foreach ($results['errors'] as $error) {
      \Drupal::messenger()
        ->addError($error);
    }
  }
  if ($success && isset($results['items'])) {
    \Drupal::service('field_encrypt.state_manager')
      ->removeStorageFields();
    $message = \Drupal::translation()
      ->formatPlural(count($results['items']), 'One entity updated.', '@count entities updated.');
    \Drupal::messenger()
      ->addMessage($message);
  }
}