You are here

public static function ExportUser::exportUsersAllOperation in Open Social 8.3

Same name and namespace in other branches
  1. 8 modules/social_features/social_user_export/src/ExportUser.php \Drupal\social_user_export\ExportUser::exportUsersAllOperation()
  2. 8.2 modules/social_features/social_user_export/src/ExportUser.php \Drupal\social_user_export\ExportUser::exportUsersAllOperation()
  3. 8.4 modules/social_features/social_user_export/src/ExportUser.php \Drupal\social_user_export\ExportUser::exportUsersAllOperation()

Callback of massive operations.

Parameters

array $conditions: Conditions of the operation.

array $context: Context of the operation.

File

modules/social_features/social_user_export/src/ExportUser.php, line 81

Class

ExportUser
Class ExportUser.

Namespace

Drupal\social_user_export

Code

public static function exportUsersAllOperation(array $conditions, array &$context) {
  if (empty($context['sandbox'])) {
    $context['sandbox']['progress'] = 0;

    // Get max uid.
    $view = _social_user_export_get_view($conditions);
    $context['sandbox']['max'] = $view->total_rows;
  }
  $view = _social_user_export_get_view($conditions, FALSE);
  $view
    ->initQuery();
  $view->query->orderby = [
    [
      'field' => 'users_field_data.uid',
      'direction' => 'ASC',
    ],
  ];
  $view
    ->setOffset($context['sandbox']['progress']);
  $view
    ->setItemsPerPage(1);
  $view
    ->preExecute();
  $view
    ->execute();
  if (empty($view->result[0])) {
    $context['finished'] = 1;
    return;
  }
  $account = $view->result[0]->_entity;
  if ($account) {
    self::exportUserOperation($account, $context);
  }
  $context['sandbox']['progress']++;
  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
  }
}