You are here

public function BatchUserAction::executeMultiple in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/tests/modules/user_batch_action_test/src/Plugin/Action/BatchUserAction.php \Drupal\user_batch_action_test\Plugin\Action\BatchUserAction::executeMultiple()

Executes the plugin for an array of objects.

Parameters

array $objects: An array of entities.

Overrides ActionBase::executeMultiple

1 call to BatchUserAction::executeMultiple()
BatchUserAction::execute in core/modules/views/tests/modules/user_batch_action_test/src/Plugin/Action/BatchUserAction.php
Executes the plugin.

File

core/modules/views/tests/modules/user_batch_action_test/src/Plugin/Action/BatchUserAction.php, line 23

Class

BatchUserAction
Provides action that sets batch precessing.

Namespace

Drupal\user_batch_action_test\Plugin\Action

Code

public function executeMultiple(array $entities) {
  $operations = [];
  foreach ($entities as $entity) {
    $operations[] = [
      [
        get_class($this),
        'processBatch',
      ],
      [
        [
          'entity_type' => $entity
            ->getEntityTypeId(),
          'entity_id' => $entity
            ->id(),
        ],
      ],
    ];
  }
  if ($operations) {
    $batch = [
      'operations' => $operations,
      'finished' => [
        get_class($this),
        'finishBatch',
      ],
    ];
    batch_set($batch);
  }
}