public static function update($ids, $status, $type, &$context) {
    // Setup.
    if (empty($context['sandbox'])) {
      $context['sandbox']['progress'] = 0;
      $context['sandbox']['max'] = count($ids);
      $context['results']['status'] = $status;
      $context['results']['type'] = $type;
    }
    $items_per_iteration = 50;

    $batch_ids = array_slice($ids, $context['sandbox']['progress'], $items_per_iteration);
    $nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($batch_ids);

    foreach ($nodes as $node) {
      if ($status && !$node->isPublished()) {
        // Publish all Activity nodes.
        $node->setPublished();
        $node->save();
      } elseif (!$status && $node->isPublished()) {
        // Unpublish all Category nodes.
        $node->setUnPublished();
        $node->save();
      }
      $context['sandbox']['progress']++;
      $context['results']['ids'][] = $node->id();
    }

    $first_node = reset($nodes);
    $context['message'] = t('Now processing %node', ['%node' => $first_node->title]);
    // When result is 1, the batch will finish.
    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
  }