You are here

public function Payment::getLineItems in Payment 8.2

Gets all line items.

Return value

\Drupal\payment\Plugin\Payment\LineItem\PaymentLineItemInterface[]

Overrides LineItemCollectionInterface::getLineItems

3 calls to Payment::getLineItems()
Payment::getAmount in src/Entity/Payment.php
Gets the line items' total amount.
Payment::getLineItem in src/Entity/Payment.php
Gets a line item.
Payment::getLineItemsByType in src/Entity/Payment.php
Gets line items by plugin type.

File

src/Entity/Payment.php, line 175

Class

Payment
Defines a payment entity.

Namespace

Drupal\payment\Entity

Code

public function getLineItems() {
  $line_items = [];

  /** @var \Drupal\plugin\Plugin\Field\FieldType\PluginCollectionItemInterface $field_item */
  foreach ($this
    ->get('line_items') as $field_item) {

    /** @var \Drupal\payment\Plugin\Payment\LineItem\PaymentLineItemInterface $line_item */
    $line_item = $field_item
      ->getContainedPluginInstance();
    if ($line_item) {
      $line_items[$line_item
        ->getName()] = $line_item;
    }
  }
  return $line_items;
}