You are here

class PaymentLineItemPaymentBasicFormElements in Payment 8.2

Hierarchy

Expanded class hierarchy of PaymentLineItemPaymentBasicFormElements

1 string reference to 'PaymentLineItemPaymentBasicFormElements'
payment_test.routing.yml in modules/payment_test/payment_test.routing.yml
modules/payment_test/payment_test.routing.yml

File

modules/payment_test/src/PaymentLineItemPaymentBasicFormElements.php, line 11

Namespace

Drupal\payment_test
View source
class PaymentLineItemPaymentBasicFormElements implements ContainerInjectionInterface, FormInterface {

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static();
  }

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'payment_test-payment-line_item-payment_basic';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    if ($form_state
      ->has('payment_line_item')) {
      $line_item = $form_state
        ->get('payment_line_item');
    }
    else {
      $line_item = Payment::lineItemManager()
        ->createInstance('payment_basic');
      $form_state
        ->set('payment_line_item', $line_item);
    }
    $form['line_item'] = $line_item
      ->buildConfigurationForm([], $form_state);
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Submit'),
    );
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {

    /** @var \Drupal\payment\Plugin\Payment\LineItem\PaymentLineItemInterface $line_item */
    $line_item = $form_state
      ->get('payment_line_item');
    $line_item
      ->validateConfigurationForm($form['line_item'], $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {

    /** @var \Drupal\payment\Plugin\Payment\LineItem\PaymentLineItemInterface $line_item */
    $line_item = $form_state
      ->get('payment_line_item');
    $line_item
      ->submitConfigurationForm($form['line_item'], $form_state);
    $form_state
      ->setRedirect('user.login');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PaymentLineItemPaymentBasicFormElements::buildForm public function Form constructor. Overrides FormInterface::buildForm
PaymentLineItemPaymentBasicFormElements::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
PaymentLineItemPaymentBasicFormElements::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
PaymentLineItemPaymentBasicFormElements::submitForm public function Form submission handler. Overrides FormInterface::submitForm
PaymentLineItemPaymentBasicFormElements::validateForm public function Form validation handler. Overrides FormInterface::validateForm