You are here

public function ContactFormListBuilder::buildRow in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/contact/src/ContactFormListBuilder.php \Drupal\contact\ContactFormListBuilder::buildRow()

Builds a row for an entity in the entity listing.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for this row of the list.

Return value

array A render array structure of fields for this entity.

Overrides EntityListBuilder::buildRow

See also

\Drupal\Core\Entity\EntityListBuilder::render()

File

core/modules/contact/src/ContactFormListBuilder.php, line 28

Class

ContactFormListBuilder
Defines a class to build a listing of contact form entities.

Namespace

Drupal\contact

Code

public function buildRow(EntityInterface $entity) {

  // Special case the personal form.
  if ($entity
    ->id() == 'personal') {
    $row['form'] = $entity
      ->label();
    $row['recipients'] = t('Selected user');
    $row['selected'] = t('No');
  }
  else {
    $row['form'] = $entity
      ->toLink(NULL, 'canonical')
      ->toString();
    $row['recipients']['data'] = [
      '#theme' => 'item_list',
      '#items' => $entity
        ->getRecipients(),
      '#context' => [
        'list_style' => 'comma-list',
      ],
    ];
    $default_form = \Drupal::config('contact.settings')
      ->get('default_form');
    $row['selected'] = $default_form == $entity
      ->id() ? t('Yes') : t('No');
  }
  return $row + parent::buildRow($entity);
}