HeartbeatListBuilder.php 969 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Drupal\heartbeat8;
  3. use Drupal\Core\Entity\EntityInterface;
  4. use Drupal\Core\Entity\EntityListBuilder;
  5. use Drupal\Core\Routing\LinkGeneratorTrait;
  6. use Drupal\Core\Url;
  7. /**
  8. * Defines a class to build a listing of Heartbeat entities.
  9. *
  10. * @ingroup heartbeat8
  11. */
  12. class HeartbeatListBuilder extends EntityListBuilder {
  13. use LinkGeneratorTrait;
  14. /**
  15. * {@inheritdoc}
  16. */
  17. public function buildHeader() {
  18. $header['id'] = $this->t('Heartbeat ID');
  19. $header['name'] = $this->t('Name');
  20. return $header + parent::buildHeader();
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function buildRow(EntityInterface $entity) {
  26. /* @var $entity \Drupal\heartbeat8\Entity\Heartbeat */
  27. $row['id'] = $entity->id();
  28. $row['name'] = $this->l(
  29. $entity->label(),
  30. new Url(
  31. 'entity.heartbeat.edit_form', array(
  32. 'heartbeat' => $entity->id(),
  33. )
  34. )
  35. );
  36. return $row + parent::buildRow($entity);
  37. }
  38. }