You are here

public function ViewsBulkOperationsActionProcessor::executeProcessing in Views Bulk Operations (VBO) 8.3

Same name and namespace in other branches
  1. 8 src/Service/ViewsBulkOperationsActionProcessor.php \Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor::executeProcessing()
  2. 8.2 src/Service/ViewsBulkOperationsActionProcessor.php \Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor::executeProcessing()
  3. 4.0.x src/Service/ViewsBulkOperationsActionProcessor.php \Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor::executeProcessing()

Helper function for processing results from view data.

Parameters

array $data: Data concerning the view that will be processed.

mixed $view: The current view object or NULL.

Overrides ViewsBulkOperationsActionProcessorInterface::executeProcessing

File

src/Service/ViewsBulkOperationsActionProcessor.php, line 476

Class

ViewsBulkOperationsActionProcessor
Defines VBO action processor.

Namespace

Drupal\views_bulk_operations\Service

Code

public function executeProcessing(array &$data, $view = NULL) {
  if (empty($data['prepopulated']) && $data['exclude_mode'] && empty($data['exclude_list'])) {
    $data['exclude_list'] = $data['list'];
    $data['list'] = [];
  }

  // Get action finished callable.
  $definition = $this->actionManager
    ->getDefinition($data['action_id']);
  if (in_array(ViewsBulkOperationsActionInterface::class, class_implements($definition['class']), TRUE)) {
    $data['finished_callback'] = [
      $definition['class'],
    ];
  }
  else {
    $data['finished_callback'] = [
      ViewsBulkOperationsBatch::class,
    ];
  }
  $data['finished_callback'][] = 'finished';
  if ($data['batch']) {
    $batch = ViewsBulkOperationsBatch::getBatch($data);
    batch_set($batch);
  }
  else {

    // Populate and process queue.
    $this
      ->initialize($data, $view);
    if (empty($data['list'])) {
      $data['list'] = $this
        ->getPageList(0);
    }
    if ($this
      ->populateQueue($data)) {
      $batch_results = $this
        ->process();
    }
    $results = [
      'operations' => [],
    ];
    foreach ($batch_results as $result) {
      $results['operations'][] = (string) $result;
    }
    $data['finished_callback'](TRUE, $results, []);
  }
}