-
-
Notifications
You must be signed in to change notification settings - Fork 560
/
listbuilder-entity-content.php.twig
55 lines (49 loc) · 1.29 KB
/
listbuilder-entity-content.php.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{% extends "base/class.php.twig" %}
{% block file_path %}
\Drupal\{{module}}\{{ entity_class }}ListBuilder.
{% endblock %}
{% block namespace_class %}
namespace Drupal\{{module}};
{% endblock %}
{% block use_class %}
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Routing\LinkGeneratorTrait;
use Drupal\Core\Url;
{% endblock %}
{% block class_declaration %}
/**
* Defines a class to build a listing of {{ label }} entities.
*
* @ingroup {{ module }}
*/
class {{ entity_class }}ListBuilder extends EntityListBuilder {% endblock %}
{% block use_trait %}
use LinkGeneratorTrait;
{% endblock %}
{% block class_methods %}
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header['id'] = $this->t('{{ label }} ID');
$header['name'] = $this->t('Name');
return $header + parent::buildHeader();
}
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
/* @var $entity \Drupal\{{module}}\Entity\{{ entity_class }} */
$row['id'] = $entity->id();
$row['name'] = $this->l(
$entity->label(),
new Url(
'entity.{{ entity_name }}.edit_form', [
'{{ entity_name }}' => $entity->id(),
]
)
);
return $row + parent::buildRow($entity);
}
{% endblock %}