public function MolliePayment::processBuildConfigurationForm in Mollie Payment 8.2
Implements a form API #process callback.
File
- src/
Plugin/ Payment/ MethodConfiguration/ MolliePayment.php, line 231
Class
- MolliePayment
- Provides the configuration for the mollie_payment payment method plugin.
Namespace
Drupal\mollie_payment\Plugin\Payment\MethodConfigurationCode
public function processBuildConfigurationForm(array &$element, FormStateInterface $form_state, array &$form) {
$element['brand_label'] = [
'#default_value' => $this
->getBrandLabel(),
'#description' => $this
->t('The label that payers will see when choosing a payment method. Defaults to the payment method label.'),
'#title' => $this
->t('Brand label'),
'#type' => 'textfield',
];
$mollie_profiles = MollieProfile::loadMultiple();
$options = [
'' => $this
->t('- Select a profile -'),
];
foreach ($mollie_profiles as $id => $mollie_profile) {
$options[$id] = $mollie_profile
->label();
}
$element['profile'] = [
'#default_value' => $this
->getProfile(),
'#description' => $this
->t('The Mollie profile that will be used to connect to Mollie.'),
'#title' => $this
->t('Mollie profile'),
'#type' => 'select',
'#options' => $options,
];
$workflow_group = implode('][', array_merge($element['#parents'], [
'workflow',
]));
$element['workflow'] = [
'#type' => 'vertical_tabs',
];
$element['execute'] = [
'#group' => $workflow_group,
'#open' => TRUE,
'#type' => 'details',
'#title' => $this
->t('Execution'),
];
$element['execute']['execute_status'] = $this
->getExecutePaymentStatusSelector($form_state)
->buildSelectorForm([], $form_state);
$element['capture'] = [
'#group' => $workflow_group,
'#open' => TRUE,
'#type' => 'details',
'#title' => $this
->t('Capture'),
];
$capture_id = Html::getUniqueId('capture');
$element['capture']['capture'] = [
'#id' => $capture_id,
'#type' => 'checkbox',
'#title' => $this
->t('Add an additional capture step after payments have been executed.'),
'#default_value' => $this
->getCapture(),
];
$element['capture']['plugin_form'] = [
'#type' => 'container',
'#states' => [
'visible' => [
'#' . $capture_id => [
'checked' => TRUE,
],
],
],
];
$element['capture']['plugin_form']['capture_status'] = $this
->getCapturePaymentStatusSelector($form_state)
->buildSelectorForm([], $form_state);
$refund_id = Html::getUniqueId('refund');
$element['refund'] = [
'#group' => $workflow_group,
'#open' => TRUE,
'#type' => 'details',
'#title' => $this
->t('Refund'),
];
$element['refund']['refund'] = [
'#id' => $refund_id,
'#type' => 'checkbox',
'#title' => $this
->t('Add an additional refund step after payments have been executed.'),
'#default_value' => $this
->getRefund(),
];
$element['refund']['plugin_form'] = [
'#type' => 'container',
'#states' => [
'visible' => [
'#' . $refund_id => [
'checked' => TRUE,
],
],
],
];
$element['refund']['plugin_form']['refund_status'] = $this
->getRefundPaymentStatusSelector($form_state)
->buildSelectorForm([], $form_state);
return $element;
}