You are here

public function PaymentOption::__construct in Commerce Core 8.2

Constructs a new PaymentOption object.

Parameters

array $definition: The definition.

File

modules/payment/src/PaymentOption.php, line 53

Class

PaymentOption
Represents a payment option.

Namespace

Drupal\commerce_payment

Code

public function __construct(array $definition) {
  foreach ([
    'id',
    'label',
    'payment_gateway_id',
  ] as $required_property) {
    if (empty($definition[$required_property])) {
      throw new \InvalidArgumentException(sprintf('Missing required property "%s".', $required_property));
    }
  }
  $this->id = $definition['id'];
  $this->label = $definition['label'];
  $this->paymentGatewayId = $definition['payment_gateway_id'];
  if (isset($definition['payment_method_id'])) {
    $this->paymentMethodId = $definition['payment_method_id'];
  }
  if (isset($definition['payment_method_type_id'])) {
    $this->paymentMethodTypeId = $definition['payment_method_type_id'];
  }
}