3 namespace Drupal\paragraphs\Controller;
5 use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
6 use Drupal\Core\Entity\EntityInterface;
9 * Provides a listing of ParagraphsType.
11 class ParagraphsTypeListBuilder extends ConfigEntityListBuilder {
16 public function buildHeader() {
17 $header['icon_file'] = [
18 'data' => $this->t('Icon'),
20 $header['label'] = $this->t('Label');
21 $header['id'] = $this->t('Machine name');
22 $header['description'] = $this->t('Description');
24 return $header + parent::buildHeader();
30 public function buildRow(EntityInterface $entity) {
31 $row['icon_file'] = [];
32 if ($icon_url = $entity->getIconUrl()) {
33 $row['icon_file']['class'][] = 'paragraphs-type-icon';
34 $row['icon_file']['data'] = [
41 $row['label'] = $entity->label();
42 $row['id'] = $entity->id();
43 $row['description']['data'] = ['#markup' => $entity->getDescription()];
44 // You probably want a few more properties here...
45 return $row + parent::buildRow($entity);
51 public function getDefaultOperations(EntityInterface $entity) {
52 /** @var \Drupal\field\FieldConfigInterface $entity */
53 $operations = parent::getDefaultOperations($entity);
55 if (isset($operations['edit'])) {
56 $operations['edit']['weight'] = 30;
65 public function render() {
66 $build = parent::render();
67 $build['#attached']['library'][] = 'paragraphs/drupal.paragraphs.list_builder';