You are here

public function ReportsListBuilder::buildRow in Commerce Reporting 8

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/ReportsListBuilder.php, line 25

Class

ReportsListBuilder
Builds a listing of the order report entities.

Namespace

Drupal\commerce_reports

Code

public function buildRow(EntityInterface $entity) {

  /** @var \Drupal\commerce_reports\Entity\OrderReportInterface $entity */
  $row['title']['data'] = [
    '#type' => 'link',
    '#title' => $entity
      ->label(),
  ] + $entity
    ->toUrl()
    ->toRenderArray();
  $row['amount']['data'] = [
    '#type' => 'inline_template',
    '#template' => '{{ amount|commerce_price_format }}',
    '#context' => [
      'amount' => $entity
        ->get('amount')
        ->first()
        ->toPrice(),
    ],
  ];
  return $row + parent::buildRow($entity);
}