public function TransactionListBuilder::buildRow in Transaction 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/
TransactionListBuilder.php, line 166  
Class
- TransactionListBuilder
 - Provides a entity list page for transactions.
 
Namespace
Drupal\transactionCode
public function buildRow(EntityInterface $entity) {
  /** @var \Drupal\transaction\TransactionInterface $entity */
  $row = [];
  $row['description'] = [
    'data' => [
      '#type' => 'container',
      'label' => [
        '#type' => 'link',
        '#title' => $entity
          ->label(),
        '#url' => $entity
          ->toUrl(),
      ],
      'details' => [
        '#theme' => 'item_list',
        '#items' => $entity
          ->getDetails(),
      ],
    ],
  ];
  $row['created'] = [
    'data' => [
      '#type' => 'container',
      'author' => [
        '#theme' => 'username',
        '#account' => $entity
          ->getOwner(),
      ],
      'date' => [
        '#type' => 'container',
        '#markup' => $this->dateFormatter
          ->format($entity
          ->getCreatedTime(), 'short'),
      ],
    ],
  ];
  $row['execution_date'] = $entity
    ->isPending() ? [
    'data' => [
      '#type' => 'html_tag',
      '#tag' => 'em',
      '#value' => $this
        ->t('- pending -'),
    ],
  ] : [
    'data' => [
      '#type' => 'container',
      'executor' => [
        '#theme' => 'username',
        '#account' => $entity
          ->getExecutor(),
      ],
      'date' => [
        '#type' => 'container',
        '#markup' => $this->dateFormatter
          ->format($entity
          ->getExecutionTime(), 'short'),
      ],
      'result' => [
        '#type' => 'container',
        '#markup' => $entity
          ->getResultMessage(),
      ],
    ],
  ];
  // Extra field values.
  $plugin_settings = $this->transactionType ? $this->transactionType
    ->getPluginSettings() : [];
  foreach (array_keys($this->extraFields) as $field_name) {
    $row['field_' . $field_name]['data'] = isset($plugin_settings[$field_name]) ? $entity
      ->get($plugin_settings[$field_name])
      ->view('list') : '';
  }
  return $row + parent::buildRow($entity);
}