class RulesDataUIPaymentSettings in Commerce Core 7
Adds a payment method settings form to the enabling action.
Hierarchy
- class \RulesDataUI
- class \RulesDataUIPaymentSettings implements RulesDataDirectInputFormInterface
Expanded class hierarchy of RulesDataUIPaymentSettings
1 string reference to 'RulesDataUIPaymentSettings'
- commerce_payment_rules_data_info in modules/
payment/ commerce_payment.rules.inc - Implements hook_rules_data_info().
File
- modules/
payment/ commerce_payment.rules.inc, line 292 - Rules integration for payments.
View source
class RulesDataUIPaymentSettings extends RulesDataUI implements RulesDataDirectInputFormInterface {
public static function getDefaultMode() {
return 'input';
}
public static function inputForm($name, $info, $settings, RulesPlugin $element) {
// If the specified payment method exists...
if (!empty($info['payment_method']) && ($payment_method = commerce_payment_method_load($info['payment_method']))) {
$form[$name]['method_id'] = array(
'#type' => 'value',
'#value' => $info['payment_method'],
);
// If the payment method has a settings callback...
if ($callback = commerce_payment_method_callback($payment_method, 'settings_form')) {
// Prepare an array of payment method settings defaults.
$method_settings = !empty($settings[$name]['settings']) && is_array($settings[$name]['settings']) ? $settings[$name]['settings'] : array();
// Add the settings form elements to the action form.
$form[$name]['settings'] = $callback($method_settings);
}
else {
// Otherwise add an appropriate message.
$form[$name]['settings']['no_settings']['#markup'] = t('No settings for this payment method.');
}
}
else {
$form[$name]['invalid']['#markup'] = t('Invalid or missing payment method.');
}
return $form;
}
public static function render($value) {
return array();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RulesDataUI:: |
public static | function | Returns the data type and parameter information for the given arguments. | |
RulesDataUI:: |
public static | function | Renders the value with a label if an options list is available. | |
RulesDataUI:: |
public static | function | Provides the selection form for a parameter. | |
RulesDataUIPaymentSettings:: |
public static | function |
Specifies the default input mode per data type. Overrides RulesDataUI:: |
|
RulesDataUIPaymentSettings:: |
public static | function |
Constructs the direct input form. Overrides RulesDataDirectInputFormInterface:: |
|
RulesDataUIPaymentSettings:: |
public static | function |
Render the configured value. Overrides RulesDataDirectInputFormInterface:: |