You are here

protected function PaymentFormConfigurationForm::getPluginSelector in Payment 8.2

Gets the plugin selector.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state:

Return value

\Drupal\plugin\Plugin\Plugin\PluginSelector\PluginSelectorInterface

1 call to PaymentFormConfigurationForm::getPluginSelector()
PaymentFormConfigurationForm::submitForm in modules/payment_form/src/Plugin/Payment/Type/PaymentFormConfigurationForm.php
Form submission handler.

File

modules/payment_form/src/Plugin/Payment/Type/PaymentFormConfigurationForm.php, line 154

Class

PaymentFormConfigurationForm
Provides the configuration form for the payment_form payment type plugin.

Namespace

Drupal\payment_form\Plugin\Payment\Type

Code

protected function getPluginSelector(FormStateInterface $form_state) {
  $config = $this
    ->config('payment_form.payment_type');
  if ($form_state
    ->has('plugin_selector')) {
    $plugin_selector = $form_state
      ->get('plugin_selector');
  }
  else {
    $plugin_selector_manager = $this->pluginSelectorType
      ->getPluginManager();
    $plugin_selector = $plugin_selector_manager
      ->createInstance('payment_radios');
    $plugin_selector
      ->setSelectablePluginType($this->pluginSelectorType);
    $plugin_selector
      ->setLabel($this
      ->t('Payment method selector'));
    $plugin_selector
      ->setRequired();
    $plugin_selector
      ->setSelectedPlugin($plugin_selector_manager
      ->createInstance($config
      ->get('plugin_selector_id')));
    $form_state
      ->set('plugin_selector', $plugin_selector);
  }
  return $plugin_selector;
}