TokenCustomListBuilder.php in Custom Tokens 8
File
src/TokenCustomListBuilder.php
View source
<?php
namespace Drupal\token_custom;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Routing\RedirectDestinationTrait;
class TokenCustomListBuilder extends EntityListBuilder {
use RedirectDestinationTrait;
public function buildHeader() {
$header['machine_name'] = $this
->t('Machine name');
$header['type'] = $this
->t('Type');
$header['name'] = $this
->t('Name');
$header['description'] = t('Description');
$header['content'] = t('Content');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['machine_name'] = $entity
->id();
$row['type'] = $entity
->bundle();
$row['name'] = $entity
->label();
$row['description'] = $entity
->getDescription();
$row['content'] = $entity
->getRawContent();
return $row + parent::buildRow($entity);
}
public function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
if (isset($operations['edit'])) {
$operations['edit']['query']['destination'] = $this
->getRedirectDestination()
->get();
}
return $operations;
}
}