You are here

public function ViewsBulkOperationsActionProcessor::initialize in Views Bulk Operations (VBO) 8

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

Set values.

Parameters

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

mixed $view: The current view object or NULL.

Overrides ViewsBulkOperationsActionProcessorInterface::initialize

1 call to ViewsBulkOperationsActionProcessor::initialize()
ViewsBulkOperationsActionProcessor::executeProcessing in src/Service/ViewsBulkOperationsActionProcessor.php
Helper function for processing results from view data.

File

src/Service/ViewsBulkOperationsActionProcessor.php, line 129

Class

ViewsBulkOperationsActionProcessor
Defines VBO action processor.

Namespace

Drupal\views_bulk_operations\Service

Code

public function initialize(array $view_data, $view = NULL) {

  // It may happen that the service was already initialized
  // in this request (e.g. multiple Batch API operation calls).
  // Clear the processing queue in such a case.
  if ($this->initialized) {
    $this->queue = [];
  }
  if (!isset($view_data['configuration'])) {
    $view_data['configuration'] = [];
  }
  if (!empty($view_data['preconfiguration'])) {
    $view_data['configuration'] += $view_data['preconfiguration'];
  }

  // Initialize action object.
  $this->actionDefinition = $this->actionManager
    ->getDefinition($view_data['action_id']);
  $this->action = $this->actionManager
    ->createInstance($view_data['action_id'], $view_data['configuration']);

  // Set action context.
  $this
    ->setActionContext($view_data);

  // Set entire view data as object parameter for future reference.
  $this->bulkFormData = $view_data;

  // Set the current view.
  $this
    ->setView($view);
  $this->initialized = TRUE;
}