ReportsListBuilder.php in Commerce Reporting 8
File
src/ReportsListBuilder.php
View source
<?php
namespace Drupal\commerce_reports;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
class ReportsListBuilder extends EntityListBuilder {
public function buildHeader() {
$header['label'] = $this
->t('Label');
$header['amount'] = $this
->t('Amount');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $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);
}
}