BlockContentTypeListBuilder.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace Drupal\block_content;
  3. use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
  4. use Drupal\Core\Entity\EntityInterface;
  5. /**
  6. * Defines a class to build a listing of custom block type entities.
  7. *
  8. * @see \Drupal\block_content\Entity\BlockContentType
  9. */
  10. class BlockContentTypeListBuilder extends ConfigEntityListBuilder {
  11. /**
  12. * {@inheritdoc}
  13. */
  14. public function getDefaultOperations(EntityInterface $entity) {
  15. $operations = parent::getDefaultOperations($entity);
  16. // Place the edit operation after the operations added by field_ui.module
  17. // which have the weights 15, 20, 25.
  18. if (isset($operations['edit'])) {
  19. $operations['edit']['weight'] = 30;
  20. }
  21. return $operations;
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function buildHeader() {
  27. $header['type'] = t('Block type');
  28. $header['description'] = t('Description');
  29. return $header + parent::buildHeader();
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function buildRow(EntityInterface $entity) {
  35. $row['type'] = $entity->link();
  36. $row['description']['data']['#markup'] = $entity->getDescription();
  37. return $row + parent::buildRow($entity);
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. protected function getTitle() {
  43. return $this->t('Custom block types');
  44. }
  45. }