PushNotificationsTokenListBuilder.php in Push Notifications 8
File
src/Entity/Controller/PushNotificationsTokenListBuilder.php
View source
<?php
namespace Drupal\push_notifications\Entity\Controller;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Component\Utility\Unicode;
class PushNotificationsTokenListBuilder extends EntityListBuilder {
public function render() {
$build['description'] = array(
'#markup' => $this
->t('List of all tokens in the database.'),
);
$build['table'] = parent::render();
$build['table']['table']['#empty'] = $this
->t('There are no device tokens registered yet.');
return $build;
}
public function buildHeader() {
$header['id'] = $this
->t('ID');
$header['owner'] = $this
->t('Owner');
$header['token'] = $this
->t('Token');
$header['network'] = $this
->t('Network');
$header['created'] = $this
->t('Created');
$header['langcode'] = $this
->t('Language Code');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['id'] = $entity
->id();
$row['owner']['data'] = array(
'#theme' => 'username',
'#account' => $entity
->getOwner(),
);
$row['token'] = Link::fromTextAndUrl(Unicode::truncate($entity
->getToken(), 80, TRUE, TRUE), Url::fromRoute('entity.push_notifications_token.canonical', array(
'push_notifications_token' => $entity
->id(),
)));
$row['network'] = $entity
->getNetwork();
$row['created'] = $entity
->getCreatedTime();
$row['langcode'] = $entity
->getLanguageCode();
return $row + parent::buildRow($entity);
}
}