You are here

public function EntityReferenceRevisionsOrphanPurger::setBatch in Entity Reference Revisions 8

Sets a batch for executing deletion of the orphaned composite entities.

Parameters

array $composite_entity_type_ids: An array of composite entity type IDs to remove orphaned items for.

File

src/EntityReferenceRevisionsOrphanPurger.php, line 240

Class

EntityReferenceRevisionsOrphanPurger
Manages orphan composite revision deletion.

Namespace

Drupal\entity_reference_revisions

Code

public function setBatch(array $composite_entity_type_ids) {
  if (empty($composite_entity_type_ids)) {
    return;
  }
  $operations = [];
  foreach ($composite_entity_type_ids as $entity_type_id) {
    $operations[] = [
      '_entity_reference_revisions_orphan_purger_batch_dispatcher',
      [
        'entity_reference_revisions.orphan_purger:deleteOrphansBatchOperation',
        $entity_type_id,
      ],
    ];
  }
  $batch = [
    'operations' => $operations,
    'finished' => [
      EntityReferenceRevisionsOrphanPurger::class,
      'batchSubmitFinished',
    ],
    'title' => $this
      ->t('Removing orphaned entities.'),
    'progress_message' => $this
      ->t('Processed @current of @total entity types.'),
    'error_message' => $this
      ->t('This batch encountered an error.'),
  ];
  batch_set($batch);
}