OpignoNotificationListBuilder.php in Opigno notifications 8
File
src/Entity/Controller/OpignoNotificationListBuilder.php
View source
<?php
namespace Drupal\opigno_notification\Entity\Controller;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\user\Entity\User;
class OpignoNotificationListBuilder extends EntityListBuilder {
public function buildHeader() {
$header['id'] = $this
->t('ID');
$header['uid'] = $this
->t('User');
$header['message'] = $this
->t('Message');
$header['has_read'] = $this
->t('Has Read');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $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);
}
}