TokenCustomTypeListBuilder.php in Custom Tokens 8
File
src/TokenCustomTypeListBuilder.php
View source
<?php
namespace Drupal\token_custom;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
class TokenCustomTypeListBuilder extends ConfigEntityListBuilder {
public function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
if (isset($operations['edit'])) {
$operations['edit']['weight'] = 30;
}
return $operations;
}
public function buildHeader() {
$header['type'] = t('Custom token type');
$header['description'] = t('Description');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['type'] = $entity
->toLink()
->toString();
$row['description']['data']['#markup'] = $entity
->getDescription();
return $row + parent::buildRow($entity);
}
protected function getTitle() {
return $this
->t('Custom token types');
}
}