Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / contact / src / ContactFormListBuilder.php
1 <?php
2
3 namespace Drupal\contact;
4
5 use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
6 use Drupal\Core\Entity\EntityInterface;
7
8 /**
9  * Defines a class to build a listing of contact form entities.
10  *
11  * @see \Drupal\contact\Entity\ContactForm
12  */
13 class ContactFormListBuilder extends ConfigEntityListBuilder {
14
15   /**
16    * {@inheritdoc}
17    */
18   public function buildHeader() {
19     $header['form'] = t('Form');
20     $header['recipients'] = t('Recipients');
21     $header['selected'] = t('Selected');
22     return $header + parent::buildHeader();
23   }
24
25   /**
26    * {@inheritdoc}
27    */
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');
34     }
35     else {
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'],
41       ];
42       $default_form = \Drupal::config('contact.settings')->get('default_form');
43       $row['selected'] = ($default_form == $entity->id() ? t('Yes') : t('No'));
44     }
45     return $row + parent::buildRow($entity);
46   }
47
48 }