You are here

function gc_views_vbo_update in GatherContent 8

Submit callback for `views_bulk_operations_confirm_form`.

This callback is used for `gc_update` action and it is substitution for VBO in order to redirect to custom view after operation is completed.

@inheritdoc

1 string reference to 'gc_views_vbo_update'
gc_views_bulk_operations_form_alter in ./_old.gc.module
Implements hook_views_bulk_operations_form_alter().

File

./_old.gc.module, line 435

Code

function gc_views_vbo_update($form, &$form_state) {
  $uuid = _gc_uuid_generate();
  $operation = \Drupal::entityManager()
    ->getStorage('gc_operation')
    ->create(array(
    'uuid' => $uuid,
    'type' => 'update',
  ));
  $operation
    ->save();
  $operations = array();
  $nodes = \Drupal::entityManager()
    ->getStorage('node')
    ->loadMultiple($form_state['selection']);
  foreach ($nodes as $node) {
    $operations[] = array(
      'gc_update_process',
      array(
        $node,
        $uuid,
      ),
    );
  }
  $batch = array(
    'title' => t('Updating content ...'),
    'operations' => $operations,
    'finished' => 'gc_update_finished',
    'init_message' => t('Update is starting ...'),
    'progress_message' => t('Processed @current out of @total.'),
    'error_message' => t('An error occurred during processing'),
  );
  batch_set($batch);
}