You are here

public function PollListBuilder::buildRow in Poll 8

Overrides Drupal\Core\Entity\EntityListController::buildRow().

Overrides DraggableListBuilder::buildRow

File

src/PollListBuilder.php, line 56

Class

PollListBuilder
Defines a class to build a listing of user role entities.

Namespace

Drupal\poll

Code

public function buildRow(EntityInterface $entity) {

  /** @var \Drupal\poll\PollVoteStorage $vote_storage */
  $vote_storage = \Drupal::service('poll_vote.storage');
  $row['question'] = $entity
    ->toLink()
    ->toString();
  $row['author']['data'] = array(
    '#theme' => 'username',
    '#account' => $entity
      ->getOwner(),
  );

  // $row['votes'] = $vote_storage->getTotalVotes($entity);
  $row['status'] = $entity
    ->isOpen() ? t('Y') : t('N');
  $row['created'] = $entity
    ->getCreated() ? Drupal::service('date.formatter')
    ->format($entity
    ->getCreated(), 'long') : t('n/a');
  return $row + parent::buildRow($entity);
}