You are here

protected function PaymentForm::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 PaymentForm::getPluginSelector()
PaymentForm::submitForm in modules/payment_form/src/Entity/Payment/PaymentForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…

File

modules/payment_form/src/Entity/Payment/PaymentForm.php, line 167

Class

PaymentForm
Provides the payment form.

Namespace

Drupal\payment_form\Entity\Payment

Code

protected function getPluginSelector(FormStateInterface $form_state) {
  if ($form_state
    ->has('plugin_selector')) {
    $plugin_selector = $form_state
      ->get('plugin_selector');
  }
  else {
    $config = $this
      ->config('payment_form.payment_type');
    $plugin_selector_id = $config
      ->get('plugin_selector_id');
    $plugin_selector = $this->pluginSelectorManager
      ->createInstance($plugin_selector_id);
    $plugin_selector
      ->setSelectablePluginType($this->paymentMethodType);
    $plugin_selector
      ->setSelectablePluginDiscovery($this
      ->getPaymentMethodManager());
    $plugin_selector
      ->setSelectablePluginFactory($this
      ->getPaymentMethodManager());
    $plugin_selector
      ->setRequired();
    $plugin_selector
      ->setLabel($this
      ->t('Payment method'));
    $form_state
      ->set('plugin_selector', $plugin_selector);
  }
  return $plugin_selector;
}