You are here

public function CommercePaymentGateway::__construct in Commerce Core 8.2

Constructs a new CommercePaymentGateway object.

Parameters

array $values: The annotation values.

Overrides Plugin::__construct

File

modules/payment/src/Annotation/CommercePaymentGateway.php, line 123

Class

CommercePaymentGateway
Defines the payment gateway plugin annotation object.

Namespace

Drupal\commerce_payment\Annotation

Code

public function __construct(array $values) {
  if (empty($values['modes'])) {
    $values['modes'] = [
      'test' => $this
        ->t('Test'),
      'live' => $this
        ->t('Live'),
    ];
  }
  if (empty($values['payment_method_types'])) {

    // NestedArray merging causes duplicates for array defaults on properties.
    $values['payment_method_types'] = [
      'credit_card',
    ];
  }
  if (empty($values['default_payment_method_type'])) {
    $values['default_payment_method_type'] = reset($values['payment_method_types']);
  }
  if (empty($values['credit_card_types'])) {
    $values['credit_card_types'] = array_keys(CreditCard::getTypes());
  }
  parent::__construct($values);
}