You are here

public function ConfigureAction::submitForm in Views Bulk Operations (VBO) 8

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

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/ConfigureAction.php, line 149

Class

ConfigureAction
Action configuration form.

Namespace

Drupal\views_bulk_operations\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $storage = $form_state
    ->getStorage();
  $form_data = $storage['views_bulk_operations'];
  $action = $this->actionManager
    ->createInstance($form_data['action_id']);
  if (method_exists($action, 'submitConfigurationForm')) {
    $action
      ->submitConfigurationForm($form, $form_state);
    $form_data['configuration'] = $action
      ->getConfiguration();
  }
  else {
    $form_state
      ->cleanValues();
    $form_data['configuration'] = $form_state
      ->getValues();
  }
  $definition = $this->actionManager
    ->getDefinition($form_data['action_id']);
  if (!empty($definition['confirm_form_route_name'])) {

    // Update tempStore data.
    $this->tempStoreFactory
      ->get($form_data['tempstore_name'])
      ->set($this
      ->currentUser()
      ->id(), $form_data);

    // Go to the confirm route.
    $form_state
      ->setRedirect($definition['confirm_form_route_name'], [
      'view_id' => $form_data['view_id'],
      'display_id' => $form_data['display_id'],
    ]);
  }
  else {
    $this->tempStoreFactory
      ->get($form_data['tempstore_name'])
      ->delete($this
      ->currentUser()
      ->id());
    $this->actionProcessor
      ->executeProcessing($form_data);
    $form_state
      ->setRedirectUrl($form_data['redirect_url']);
  }
}