class PaymentLineItemPaymentBasicFormElements in Payment 8.2
Hierarchy
- class \Drupal\payment_test\PaymentLineItemPaymentBasicFormElements implements ContainerInjectionInterface, FormInterface
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_testView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PaymentLineItemPaymentBasicFormElements:: |
public | function |
Form constructor. Overrides FormInterface:: |
|
PaymentLineItemPaymentBasicFormElements:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
PaymentLineItemPaymentBasicFormElements:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
PaymentLineItemPaymentBasicFormElements:: |
public | function |
Form submission handler. Overrides FormInterface:: |
|
PaymentLineItemPaymentBasicFormElements:: |
public | function |
Form validation handler. Overrides FormInterface:: |