ExportEntityListBuilder.php in Content Synchronizer 8.2
File
src/ExportEntityListBuilder.php
View source
<?php
namespace Drupal\content_synchronizer;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Routing\LinkGeneratorTrait;
use Drupal\Core\Url;
class ExportEntityListBuilder extends EntityListBuilder {
use LinkGeneratorTrait;
public function buildHeader() {
$header['id'] = $this
->t('Export entity ID');
$header['name'] = $this
->t('Name');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['id'] = $entity
->id();
$row['name'] = $this
->l($entity
->label(), new Url('entity.export_entity.canonical', [
'export_entity' => $entity
->id(),
]));
return $row + parent::buildRow($entity);
}
public function getOperations(EntityInterface $entity) {
$operations = parent::getOperations($entity);
$operations['view'] = [
'title' => t('Export'),
'weight' => 1,
'url' => new Url('entity.export_entity.canonical', [
'export_entity' => $entity
->id(),
]),
];
usort($operations, function ($a, $b) {
if ($a['weight'] > $b['weight']) {
return 1;
}
return -1;
});
return $operations;
}
}