You are here

public static function SocialProfilePrivacyBatchHelper::bulkUpdateProfileNames in Open Social 10.2.x

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_profile/modules/social_profile_privacy/src/Service/SocialProfilePrivacyBatchHelper.php \Drupal\social_profile_privacy\Service\SocialProfilePrivacyBatchHelper::bulkUpdateProfileNames()

Update profile names in a batch.

1 call to SocialProfilePrivacyBatchHelper::bulkUpdateProfileNames()
social_profile_privacy_admin_settings_form_submit in modules/social_features/social_profile/modules/social_profile_privacy/social_profile_privacy.module
The submit function for social_profile_admin_settings_form().

File

modules/social_features/social_profile/modules/social_profile_privacy/src/Service/SocialProfilePrivacyBatchHelper.php, line 20

Class

SocialProfilePrivacyBatchHelper
Class SocialProfilePrivacyBatchHelper.

Namespace

Drupal\social_profile_privacy\Service

Code

public static function bulkUpdateProfileNames() {

  /** @var \Drupal\profile\ProfileStorageInterface $profile_storage */
  $profile_storage = \Drupal::entityTypeManager()
    ->getStorage('profile');
  $pids = $profile_storage
    ->getQuery()
    ->accessCheck(FALSE)
    ->execute();

  // Define batch process to update profile names.
  $batch_builder = (new BatchBuilder())
    ->setTitle(t('Updating profile names...'))
    ->setFinishCallback([
    SocialProfilePrivacyBatchHelper::class,
    'finishProcess',
  ])
    ->addOperation([
    SocialProfilePrivacyBatchHelper::class,
    'updateProcess',
  ], [
    $pids,
  ]);
  batch_set($batch_builder
    ->toArray());
}