You are here

public static function SocialBulkGroupInvitation::batchFinished in Open Social 10.0.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_group/modules/social_group_invite/src/Form/SocialBulkGroupInvitation.php \Drupal\social_group_invite\Form\SocialBulkGroupInvitation::batchFinished()
  2. 10.3.x modules/social_features/social_group/modules/social_group_invite/src/Form/SocialBulkGroupInvitation.php \Drupal\social_group_invite\Form\SocialBulkGroupInvitation::batchFinished()
  3. 10.1.x modules/social_features/social_group/modules/social_group_invite/src/Form/SocialBulkGroupInvitation.php \Drupal\social_group_invite\Form\SocialBulkGroupInvitation::batchFinished()
  4. 10.2.x modules/social_features/social_group/modules/social_group_invite/src/Form/SocialBulkGroupInvitation.php \Drupal\social_group_invite\Form\SocialBulkGroupInvitation::batchFinished()

Batch finished callback overridden from BulkGroupInvitationConfirm.

File

modules/social_features/social_group/modules/social_group_invite/src/Form/SocialBulkGroupInvitation.php, line 421

Class

SocialBulkGroupInvitation
Class SocialBulkGroupInvitation.

Namespace

Drupal\social_group_invite\Form

Code

public static function batchFinished($success, $results, $operations) {
  if ($success) {
    try {
      $tempstore = \Drupal::service('tempstore.private')
        ->get('ginvite_bulk_invitation');
      $params = $tempstore
        ->get('params')['gid'];

      // BulkGroupInvitationConfirm sends us to
      // $destination = new Url('view.group_invitations.page_1',
      // ['group' => $tempstore->get('params')['gid']]);
      // however we want to go to the group canonical.
      $destination = new Url('entity.group.canonical', [
        'group' => $tempstore
          ->get('params')['gid'],
      ]);
      $redirect = new RedirectResponse($destination
        ->toString());
      $tempstore
        ->delete('params');
      $redirect
        ->send();
    } catch (\Exception $error) {
      \Drupal::service('logger.factory')
        ->get('social_group_invite')
        ->alert(new TranslatableMarkup('@err', [
        '@err' => $error,
      ]));
    }
  }
  else {
    $error_operation = reset($operations);
    \Drupal::service('messenger')
      ->addMessage(new TranslatableMarkup('An error occurred while processing @operation with arguments : @args', [
      '@operation' => $error_operation[0],
      '@args' => print_r($error_operation[0]),
    ]));
  }
}