You are here

protected function ViewsBulkOperationsFormTrait::getFormData in Views Bulk Operations (VBO) 8

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

Helper function to prepare data needed for proper form display.

Parameters

string $view_id: The current view ID.

string $display_id: The current view display ID.

Return value

array Array containing data for the form builder.

2 calls to ViewsBulkOperationsFormTrait::getFormData()
ConfigureAction::buildForm in src/Form/ConfigureAction.php
Form constructor.
ConfirmAction::buildForm in src/Form/ConfirmAction.php
Form constructor.

File

src/Form/ViewsBulkOperationsFormTrait.php, line 21

Class

ViewsBulkOperationsFormTrait
Defines common methods for Views Bulk Operations forms.

Namespace

Drupal\views_bulk_operations\Form

Code

protected function getFormData($view_id, $display_id) {

  // Get tempstore data.
  $tempstore_name = 'views_bulk_operations_' . $view_id . '_' . $display_id;
  $tempstore = $this->tempStoreFactory
    ->get($tempstore_name);
  $form_data = $tempstore
    ->get($this
    ->currentUser()
    ->id());
  $form_data['tempstore_name'] = $tempstore_name;

  // Get data needed for selected entities list.
  if (!empty($form_data['entity_labels'])) {
    $form_data['selected_count'] = count($form_data['entity_labels']);
  }
  elseif ($form_data['total_results']) {
    $form_data['selected_count'] = $form_data['total_results'];
  }
  else {
    $form_data['selected_count'] = (string) $this
      ->t('all');
  }
  return $form_data;
}