You are here

public function PaymentStorage::create in Payment 8.2

Constructs a new entity object, without permanently saving it.

Parameters

array $values: (optional) An array of values to set, keyed by property name. If the entity type has bundles, the bundle key has to be specified.

Return value

\Drupal\Core\Entity\EntityInterface A new entity object.

Overrides EntityStorageBase::create

File

src/Entity/Payment/PaymentStorage.php, line 43

Class

PaymentStorage
Handles storage for payment entities.

Namespace

Drupal\payment\Entity\Payment

Code

public function create(array $values = []) {

  /** @var \Drupal\payment\Entity\PaymentInterface $payment */
  $payment = parent::create($values);
  $payment_type = $this->paymentTypeManager
    ->createInstance($values['bundle']);
  $payment_type
    ->setPayment($payment);
  $payment
    ->get('payment_type')
    ->setValue($payment_type);
  $status = $this->paymentStatusManager
    ->createInstance('payment_created')
    ->setCreated(time());
  $payment
    ->setPaymentStatus($status);
  return $payment;
}