BlockContentListBuilder.php 997 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Drupal\block_content;
  3. use Drupal\Core\Entity\EntityInterface;
  4. use Drupal\Core\Entity\EntityListBuilder;
  5. /**
  6. * Defines a class to build a listing of custom block entities.
  7. *
  8. * @see \Drupal\block_content\Entity\BlockContent
  9. */
  10. class BlockContentListBuilder extends EntityListBuilder {
  11. /**
  12. * {@inheritdoc}
  13. */
  14. public function buildHeader() {
  15. $header['label'] = t('Block description');
  16. return $header + parent::buildHeader();
  17. }
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public function buildRow(EntityInterface $entity) {
  22. $row['label'] = $entity->label();
  23. return $row + parent::buildRow($entity);
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. protected function getEntityIds() {
  29. $query = $this->getStorage()->getQuery()
  30. ->sort($this->entityType->getKey('id'));
  31. $query->condition('reusable', TRUE);
  32. // Only add the pager if a limit is specified.
  33. if ($this->limit) {
  34. $query->pager($this->limit);
  35. }
  36. return $query->execute();
  37. }
  38. }