8de78d50b855e8f427b190364ab4b14ac78c18e1
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / module / configuration-entity / src / ExampleListBuilder.php.twig
1 <?php
2
3 namespace Drupal\{{ machine_name }};
4
5 use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
6 use Drupal\Core\Entity\EntityInterface;
7
8 /**
9  * Provides a listing of {{ entity_type_label|lower|plural }}.
10  */
11 class {{ class_prefix }}ListBuilder extends ConfigEntityListBuilder {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function buildHeader() {
17     $header['label'] = $this->t('Label');
18     $header['id'] = $this->t('Machine name');
19     $header['status'] = $this->t('Status');
20     return $header + parent::buildHeader();
21   }
22
23   /**
24    * {@inheritdoc}
25    */
26   public function buildRow(EntityInterface $entity) {
27     /** @var \Drupal\{{ machine_name }}\{{ class_prefix }}Interface $entity */
28     $row['label'] = $entity->label();
29     $row['id'] = $entity->id();
30     $row['status'] = $entity->status() ? $this->t('Enabled') : $this->t('Disabled');
31     return $row + parent::buildRow($entity);
32   }
33
34 }