You are here

public function PriceListItemListBuilder::buildRow in Commerce Pricelist 8.2

Builds a row for an entity in the entity listing.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for this row of the list.

Return value

array A render array structure of fields for this entity.

Overrides EntityListBuilder::buildRow

See also

\Drupal\Core\Entity\EntityListBuilder::render()

File

src/PriceListItemListBuilder.php, line 95

Class

PriceListItemListBuilder
Defines the list builder for price list items.

Namespace

Drupal\commerce_pricelist

Code

public function buildRow(EntityInterface $entity) {

  /* @var \Drupal\commerce_pricelist\Entity\PriceListItemInterface $entity */
  $row['purchasable_entity'] = $entity
    ->getPurchasableEntity()
    ->getOrderItemTitle();
  $row['quantity'] = Calculator::trim($entity
    ->getQuantity());
  $row['list_price'] = [
    'data' => [
      '#type' => 'inline_template',
      '#template' => '{{list_price|commerce_price_format|default("N/A")}}',
      '#context' => [
        'list_price' => $entity
          ->getListPrice(),
      ],
    ],
  ];
  $row['price'] = [
    'data' => [
      '#type' => 'inline_template',
      '#template' => '{{price|commerce_price_format}}',
      '#context' => [
        'price' => $entity
          ->getPrice(),
      ],
    ],
  ];
  $row['status'] = $entity
    ->isEnabled() ? $this
    ->t('Enabled') : $this
    ->t('Disabled');
  return $row + parent::buildRow($entity);
}