EntityExportCsvListBuilder.php in Entity Export CSV 8
File
src/EntityExportCsvListBuilder.php
View source
<?php
namespace Drupal\entity_export_csv;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
class EntityExportCsvListBuilder extends ConfigEntityListBuilder {
public function buildHeader() {
$header['label'] = $this
->t('Label');
$header['id'] = $this
->t('Machine name');
$header['entity_type_id'] = $this
->t('Entity Type ID');
$header['bundle'] = $this
->t('Bundle');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity
->label();
$row['id'] = $entity
->id();
$row['entity_type_id'] = $entity
->getTargetEntityTypeId();
$row['bundle'] = $entity
->getTargetBundle();
return $row + parent::buildRow($entity);
}
public function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
if ($entity
->hasLinkTemplate('duplicate')) {
$operations['duplicate'] = [
'title' => $this
->t('Duplicate'),
'weight' => 15,
'url' => $this
->ensureDestination($entity
->toUrl('duplicate')),
];
}
return $operations;
}
}