protected function PaymentStorage::doCreate in Commerce Core 8.2
Performs storage-specific creation of entities.
Parameters
array $values: An array of values to set, keyed by property name.
Return value
\Drupal\Core\Entity\EntityInterface
Overrides ContentEntityStorageBase::doCreate
File
- modules/
payment/ src/ PaymentStorage.php, line 39
Class
- PaymentStorage
- Defines the payment storage.
Namespace
Drupal\commerce_paymentCode
protected function doCreate(array $values) {
// Populate the type using the payment gateway.
if (!isset($values['type']) && !empty($values['payment_gateway'])) {
$payment_gateway = $values['payment_gateway'];
if (is_string($payment_gateway)) {
// The caller passed tha payment gateway ID, load the full entity.
$payment_gateway_storage = $this->entityTypeManager
->getStorage('commerce_payment_gateway');
/** @var \Drupal\commerce_payment\Entity\PaymentGatewayInterface $payment_gateway */
$payment_gateway = $payment_gateway_storage
->load($payment_gateway);
}
$payment_type = $payment_gateway
->getPlugin()
->getPaymentType();
$values['type'] = $payment_type
->getPluginId();
}
return parent::doCreate($values);
}