public function Payment::setPaymentMethod in Payment 8.2
Gets the payment method plugin.
Parameters
\Drupal\payment\Plugin\Payment\Method\PaymentMethodInterface:
Return value
static
Overrides PaymentInterface::setPaymentMethod
File
- src/
Entity/ Payment.php, line 284
Class
- Payment
- Defines a payment entity.
Namespace
Drupal\payment\EntityCode
public function setPaymentMethod(PluginPaymentMethodInterface $payment_method) {
// The payment method might have been unserialized with an old payment
// object, trying to save that as new will result in exceptions. Set the
// current object again.
$payment_method
->setPayment($this);
/** @var \Drupal\plugin\Plugin\Field\FieldType\PluginCollectionItemInterface $field_item */
$this
->get('payment_method')
->applyDefaultValue();
$this
->get('payment_method')
->appendItem($payment_method);
return $this;
}