public static function performFlush(array $pids, array $fields, array &$context) {
    $message = 'Flushing profile data...';

    $results = [];

    foreach ($pids as $pid) {
      $profile = Profile::load($pid);

      foreach ($fields as $field_name) {
        // Check if the field exists.
        if ($profile->hasField($field_name)) {
          // Empty the field.
          $profile->set($field_name, '');
        }
      }
      // Save the profile.
      $results[] = $profile->save();
      // Oh and also clear the profile cache while we're at it.
      Cache::invalidateTags(['profile:' . $profile->id()]);
    }
    $context['message'] = $message;
    $context['results'] = $results;
  }
public static function performFlush(array $pids, array $fields, array &$context) {
    $message = 'Flushing profile data...';

    $results = [];

    foreach ($pids as $pid) {
      $profile = Profile::load($pid);

      foreach ($fields as $field_name) {
        // Check if the field exists.
        if ($profile->hasField($field_name)) {
          // Empty the field.
          $profile->set($field_name, '');
        }
      }
      // Save the profile.
      $results[] = $profile->save();
      // Oh and also clear the profile cache while we're at it.
      Cache::invalidateTags(['profile:' . $profile->id()]);
    }
    $context['message'] = $message;
    $context['results'] = $results;
  }
public static function performFlush ( array $ pids , array $ fields , array & $ context ) { $ message = 'Flushing profile data...' ; $ results = [ ] ; foreach ( $ pids as $ pid ) { $ profile = Profile :: load ( $ pid ) ; foreach ( $ fields as $ field_name ) { // Check if the field exists. if ( $ profile -> hasField ( $ field_name ) ) { // Empty the field. $ profile -> set ( $ field_name , '' ) ; } } // Save the profile. $ results [ ] = $ profile -> save ( ) ; // Oh and also clear the profile cache while we're at it. Cache :: invalidateTags ( [ 'profile:' . $ profile -> id ( ) ] ) ; } $ context [ 'message' ] = $ message ; $ context [ 'results' ] = $ results ; }
Perform the flush.

@param array $pids
Profile id's.
@param array $fields
An array of fields to empty.
@param array $context
The context of the flush.
Perform the flush .