Version 1
[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\Routing\LinkGeneratorTrait;
15 use Drupal\Core\Url;
16 {% endblock %}
17
18 {% block class_declaration %}
19 /**
20  * Defines a class to build a listing of {{ label }} entities.
21  *
22  * @ingroup {{ module }}
23  */
24 class {{ entity_class }}ListBuilder extends EntityListBuilder {% endblock %}
25 {% block use_trait %}
26   use LinkGeneratorTrait;
27 {% endblock %}
28 {% block class_methods %}
29
30   /**
31    * {@inheritdoc}
32    */
33   public function buildHeader() {
34     $header['id'] = $this->t('{{ label }} ID');
35     $header['name'] = $this->t('Name');
36     return $header + parent::buildHeader();
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   public function buildRow(EntityInterface $entity) {
43     /* @var $entity \Drupal\{{module}}\Entity\{{ entity_class }} */
44     $row['id'] = $entity->id();
45     $row['name'] = $this->l(
46       $entity->label(),
47       new Url(
48         'entity.{{ entity_name }}.edit_form', array(
49           '{{ entity_name }}' => $entity->id(),
50         )
51       )
52     );
53     return $row + parent::buildRow($entity);
54   }
55 {% endblock %}