3 namespace Drupal\contact;
5 use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
6 use Drupal\Core\Entity\EntityInterface;
9 * Defines a class to build a listing of contact form entities.
11 * @see \Drupal\contact\Entity\ContactForm
13 class ContactFormListBuilder extends ConfigEntityListBuilder {
18 public function buildHeader() {
19 $header['form'] = t('Form');
20 $header['recipients'] = t('Recipients');
21 $header['selected'] = t('Selected');
22 return $header + parent::buildHeader();
28 public function buildRow(EntityInterface $entity) {
29 // Special case the personal form.
30 if ($entity->id() == 'personal') {
31 $row['form'] = $entity->label();
32 $row['recipients'] = t('Selected user');
33 $row['selected'] = t('No');
36 $row['form'] = $entity->link(NULL, 'canonical');
37 $row['recipients']['data'] = [
38 '#theme' => 'item_list',
39 '#items' => $entity->getRecipients(),
40 '#context' => ['list_style' => 'comma-list'],
42 $default_form = \Drupal::config('contact.settings')->get('default_form');
43 $row['selected'] = ($default_form == $entity->id() ? t('Yes') : t('No'));
45 return $row + parent::buildRow($entity);