More tidying.
[yaffs-website] / vendor / drupal / console / templates / module / src / listbuilder-entity-content.php.twig
1 {% extends "base/class.php.twig" %}
2
3 {% block file_path %}
4 \Drupal\{{module}}\{{ entity_class }}ListBuilder.
5 {% endblock %}
6
7 {% block namespace_class %}
8 namespace Drupal\{{module}};
9 {% endblock %}
10
11 {% block use_class %}
12 use Drupal\Core\Entity\EntityInterface;
13 use Drupal\Core\Entity\EntityListBuilder;
14 use Drupal\Core\Link;
15 {% endblock %}
16
17 {% block class_declaration %}
18 /**
19  * Defines a class to build a listing of {{ label }} entities.
20  *
21  * @ingroup {{ module }}
22  */
23 class {{ entity_class }}ListBuilder extends EntityListBuilder {% endblock %}
24 {% block class_methods %}
25
26   /**
27    * {@inheritdoc}
28    */
29   public function buildHeader() {
30     $header['id'] = $this->t('{{ label }} ID');
31     $header['name'] = $this->t('Name');
32     return $header + parent::buildHeader();
33   }
34
35   /**
36    * {@inheritdoc}
37    */
38   public function buildRow(EntityInterface $entity) {
39     /* @var $entity \Drupal\{{module}}\Entity\{{ entity_class }} */
40     $row['id'] = $entity->id();
41     $row['name'] = Link::createFromRoute(
42       $entity->label(),
43       'entity.{{ entity_name }}.edit_form',
44       ['{{ entity_name }}' => $entity->id()]
45     );
46     return $row + parent::buildRow($entity);
47   }
48 {% endblock %}