You are here

class MerciConfigureAction in MERCI (Manage Equipment Reservations, Checkout and Inventory) 8.2

Action configuration form.

Hierarchy

  • class \Drupal\merci_line_item\Form\MerciConfigureAction extends \Drupal\views_bulk_operations\Form\ConfigureAction

Expanded class hierarchy of MerciConfigureAction

File

modules/merci_line_item/src/Form/MerciConfigureAction.php, line 17

Namespace

Drupal\merci_line_item\Form
View source
class MerciConfigureAction extends ConfigureAction {

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state, $view_id = NULL, $display_id = NULL) {
    $form = parent::buildForm($form, $form_state, $view_id, $display_id);
    $form['actions']['cancel']['#submit'][] = [
      $this,
      'cancelFormData',
    ];
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $form_data = $form_state
      ->get('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();
    }
    if ($form_state
      ->isRebuilding()) {
      return;
    }
    $definition = $this->actionManager
      ->getDefinition($form_data['action_id']);
    if (!empty($definition['confirm_form_route_name'])) {

      // Update tempStore data.
      $this
        ->setTempstoreData($form_data, $form_data['view_id'], $form_data['display_id']);

      // 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
        ->deleteTempstoreData($form_data['view_id'], $form_data['display_id']);
      $this->actionProcessor
        ->executeProcessing($form_data);
      $form_state
        ->setRedirectUrl($form_data['redirect_url']);
    }
  }

  /**
   * Submit callback to cancel an action and return to the view.
   *
   * @param array $form
   *   The form definition.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The form state.
   */
  public function cancelFormData(array &$form, FormStateInterface $form_state) {
    $form_data = $form_state
      ->get('views_bulk_operations');
    $this
      ->getTempstore($form_data['view_id'], $form_data['display_id'])
      ->delete('validation_errors');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MerciConfigureAction::buildForm public function
MerciConfigureAction::cancelFormData public function Submit callback to cancel an action and return to the view.
MerciConfigureAction::submitForm public function