You are here

public function OpignoNotificationListBuilder::buildRow in Opigno notifications 8

Same name and namespace in other branches
  1. 3.x src/Entity/Controller/OpignoNotificationListBuilder.php \Drupal\opigno_notification\Entity\Controller\OpignoNotificationListBuilder::buildRow()

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/Entity/Controller/OpignoNotificationListBuilder.php, line 30

Class

OpignoNotificationListBuilder
Provides a list controller for opigno_notification entity.

Namespace

Drupal\opigno_notification\Entity\Controller

Code

public function buildRow(EntityInterface $entity) {

  /* @var \Drupal\opigno_notification\OpignoNotificationInterface $entity */
  $row['id'] = $entity
    ->id();
  $user_id = $entity
    ->getUser();
  if ($user_id && ($user = User::load($user_id))) {
    $row['uid'] = $user
      ->toLink()
      ->toString();
  }
  else {
    $user_id = $user_id ? ' (id: ' . $user_id . ')' : '';
    $row['uid'] = t('User not exists') . $user_id;
  }
  $row['message'] = $entity
    ->getMessage();
  $row['has_read'] = $entity
    ->getHasRead() ? 'Yes' : 'No';
  return $row + parent::buildRow($entity);
}