You are here

protected function PaymentStorage::mapToStorageRecord in Payment 8.2

Maps from an entity object to the storage record.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity object.

string $table_name: (optional) The table name to map records to. Defaults to the base table.

Return value

object The record to store.

Overrides SqlContentEntityStorage::mapToStorageRecord

File

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

Class

PaymentStorage
Handles storage for payment entities.

Namespace

Drupal\payment\Entity\Payment

Code

protected function mapToStorageRecord(ContentEntityInterface $entity, $table_name = NULL) {

  /** @var \Drupal\payment\Entity\PaymentInterface $payment */
  $payment = $entity;
  $record = parent::mapToStorageRecord($entity, $table_name);
  $deltas = [];
  foreach ($payment
    ->getPaymentStatuses() as $delta => $item) {
    $deltas[] = $delta;
  }
  $record->current_payment_status_delta = max($deltas);
  return $record;
}