You are here

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;

/**
 * Provides a listing of Entity export csv entities.
 */
class EntityExportCsvListBuilder extends ConfigEntityListBuilder {

  /**
   * {@inheritdoc}
   */
  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();
  }

  /**
   * {@inheritdoc}
   */
  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);
  }

  /**
   * {@inheritdoc}
   */
  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;
  }

}

Classes

Namesort descending Description
EntityExportCsvListBuilder Provides a listing of Entity export csv entities.