public function ViewsBulkOperationsActionProcessor::process in Views Bulk Operations (VBO) 8.3
Same name and namespace in other branches
- 8 src/Service/ViewsBulkOperationsActionProcessor.php \Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor::process()
- 8.2 src/Service/ViewsBulkOperationsActionProcessor.php \Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor::process()
- 4.0.x src/Service/ViewsBulkOperationsActionProcessor.php \Drupal\views_bulk_operations\Service\ViewsBulkOperationsActionProcessor::process()
Process results.
Overrides ViewsBulkOperationsActionProcessorInterface::process
1 call to ViewsBulkOperationsActionProcessor::process()
- ViewsBulkOperationsActionProcessor::executeProcessing in src/
Service/ ViewsBulkOperationsActionProcessor.php - Helper function for processing results from view data.
File
- src/
Service/ ViewsBulkOperationsActionProcessor.php, line 429
Class
- ViewsBulkOperationsActionProcessor
- Defines VBO action processor.
Namespace
Drupal\views_bulk_operations\ServiceCode
public function process() {
$output = [];
// Check if all queue items are actually Drupal entities.
foreach ($this->queue as $delta => $entity) {
if (!$entity instanceof EntityInterface) {
$output[] = $this
->t('Skipped');
unset($this->queue[$delta]);
}
}
// Check entity type for multi-type views like search_api index.
$action_definition = $this->actionManager
->getDefinition($this->bulkFormData['action_id']);
if (!empty($action_definition['type'])) {
foreach ($this->queue as $delta => $entity) {
if ($entity
->getEntityTypeId() !== $action_definition['type']) {
$output[] = $this
->t('Entity type not supported');
unset($this->queue[$delta]);
}
}
}
// Check access.
foreach ($this->queue as $delta => $entity) {
if (!$this->action
->access($entity, $this->currentUser)) {
$output[] = $this
->t('Access denied');
unset($this->queue[$delta]);
}
}
// Process queue.
$results = $this->action
->executeMultiple($this->queue);
// Populate output.
if (empty($results)) {
$count = count($this->queue);
for ($i = 0; $i < $count; $i++) {
$output[] = $this->bulkFormData['action_label'];
}
return $output;
}
return array_merge($output, $results);
}