Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
ContactDetailListBuilder | |
0.00% |
0 / 16 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
buildHeader | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
buildRow | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Drupal\crm; |
6 | |
7 | use Drupal\Core\Entity\EntityInterface; |
8 | use Drupal\Core\Entity\EntityListBuilder; |
9 | |
10 | /** |
11 | * Provides a list controller for the CRM contact detail entity type. |
12 | */ |
13 | final class ContactDetailListBuilder extends EntityListBuilder { |
14 | |
15 | /** |
16 | * {@inheritdoc} |
17 | */ |
18 | public function buildHeader(): array { |
19 | $header['id'] = $this->t('ID'); |
20 | $header['status'] = $this->t('Status'); |
21 | $header['uid'] = $this->t('Author'); |
22 | $header['created'] = $this->t('Created'); |
23 | $header['changed'] = $this->t('Updated'); |
24 | return $header + parent::buildHeader(); |
25 | } |
26 | |
27 | /** |
28 | * {@inheritdoc} |
29 | */ |
30 | public function buildRow(EntityInterface $entity): array { |
31 | /** @var \Drupal\crm\CRMContactDetailInterface $entity */ |
32 | $row['id'] = $entity->id(); |
33 | $row['status'] = $entity->get('status')->value ? $this->t('Enabled') : $this->t('Disabled'); |
34 | $username_options = [ |
35 | 'label' => 'hidden', |
36 | 'settings' => ['link' => $entity->get('uid')->entity->isAuthenticated()], |
37 | ]; |
38 | $row['uid']['data'] = $entity->get('uid')->view($username_options); |
39 | $row['created']['data'] = $entity->get('created')->view(['label' => 'hidden']); |
40 | $row['changed']['data'] = $entity->get('changed')->view(['label' => 'hidden']); |
41 | return $row + parent::buildRow($entity); |
42 | } |
43 | |
44 | } |