You are here

public static function PaymentForm::create in Payment 8.2

Same name in this branch
  1. 8.2 modules/payment_form/src/Entity/Payment/PaymentForm.php \Drupal\payment_form\Entity\Payment\PaymentForm::create()
  2. 8.2 modules/payment_form/src/Plugin/Payment/Type/PaymentForm.php \Drupal\payment_form\Plugin\Payment\Type\PaymentForm::create()
  3. 8.2 modules/payment_form/src/Plugin/Field/FieldFormatter/PaymentForm.php \Drupal\payment_form\Plugin\Field\FieldFormatter\PaymentForm::create()
  4. 8.2 modules/payment_form/src/Plugin/Field/FieldWidget/PaymentForm.php \Drupal\payment_form\Plugin\Field\FieldWidget\PaymentForm::create()

Instantiates a new instance of this class.

This is a factory method that returns a new instance of this class. The factory should pass any needed dependencies into the constructor of this class, but not the container itself. Every call to this method must return a new instance of this class; that is, it may not implement a singleton.

Parameters

\Symfony\Component\DependencyInjection\ContainerInterface $container: The service container this instance should use.

Overrides ContentEntityForm::create

File

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

Class

PaymentForm
Provides the payment form.

Namespace

Drupal\payment_form\Entity\Payment

Code

public static function create(ContainerInterface $container) {

  /** @var \Drupal\plugin\PluginType\PluginTypeManagerInterface $plugin_type_manager */
  $plugin_type_manager = $container
    ->get('plugin.plugin_type_manager');

  /** @var static $form */
  $form = parent::create($container);
  $form->currentUser = $container
    ->get('current_user');
  $form->paymentMethodType = $plugin_type_manager
    ->getPluginType('payment_method');
  $form->pluginSelectorManager = $container
    ->get('plugin.manager.plugin.plugin_selector');
  $form->urlGenerator = $container
    ->get('url_generator');
  $form->stringTranslation = $container
    ->get('string_translation');
  return $form;
}