Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
ContactTypeListBuilder
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 4
30
0.00% covered (danger)
0.00%
0 / 1
 buildHeader
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 buildRow
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 render
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 getDefaultOperations
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace Drupal\crm;
4
5use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
6use Drupal\Core\Entity\EntityInterface;
7use Drupal\Core\Url;
8
9/**
10 * Defines a class to build a listing of contact type entities.
11 *
12 * @see \Drupal\crm\Entity\ContactType
13 */
14class ContactTypeListBuilder extends ConfigEntityListBuilder {
15
16  /**
17   * {@inheritdoc}
18   */
19  public function buildHeader() {
20    $header['label'] = $this->t('Label');
21    $header['description'] = [
22      'data' => $this->t('Description'),
23      'class' => [RESPONSIVE_PRIORITY_MEDIUM],
24    ];
25
26    return $header + parent::buildHeader();
27  }
28
29  /**
30   * {@inheritdoc}
31   */
32  public function buildRow(EntityInterface $entity) {
33    $row['label'] = [
34      'data' => $entity->label(),
35      'class' => ['menu-label'],
36    ];
37    $row['description']['data'] = ['#markup' => $entity->getDescription()];
38
39    return $row + parent::buildRow($entity);
40  }
41
42  /**
43   * {@inheritdoc}
44   */
45  public function render() {
46    $build = parent::render();
47
48    $build['table']['#empty'] = $this->t(
49      'No contact types available. <a href=":link">Add contact type</a>.',
50      [':link' => Url::fromRoute('entity.crm_contact_type.add_form')->toString()]
51    );
52
53    return $build;
54  }
55
56  /**
57   * {@inheritdoc}
58   */
59  public function getDefaultOperations(EntityInterface $entity) {
60    $operations = parent::getDefaultOperations($entity);
61    // Place the edit operation after the operations added by field_ui.module
62    // which have the weights 15, 20, 25.
63    if (isset($operations['edit'])) {
64      $operations['edit']['weight'] = 30;
65    }
66    return $operations;
67  }
68
69}