You are here

protected function ContactEmailListBuilder::getRecipients in Contact Emails 8

Gets the recipient text to display.

Parameters

\Drupal\contact_emails\Entity\ContactEmailInterface $entity: The contact email entity.

Return value

string The recipients text.

1 call to ContactEmailListBuilder::getRecipients()
ContactEmailListBuilder::buildRow in src/ContactEmailListBuilder.php
Builds a row for an entity in the entity listing.

File

src/ContactEmailListBuilder.php, line 72

Class

ContactEmailListBuilder
Defines the list builder for tax services.

Namespace

Drupal\contact_emails

Code

protected function getRecipients(ContactEmailInterface $entity) {
  switch ($entity
    ->get('recipient_type')->value) {
    case 'default':
      $value = $this
        ->t('[The site email address]');
      break;
    case 'submitter':
      $value = $this
        ->t('[The submitter of the form]');
      break;
    case 'field':
      $value = $this
        ->recipientFieldValue($entity, 'recipient_field', 'email');
      break;
    case 'reference':
      $value = $this
        ->recipientFieldValue($entity, 'recipient_reference', 'entity_reference');
      break;
    case 'manual':
    default:
      $recipients = [];
      foreach ($entity
        ->get('recipients')
        ->getValue() as $value) {
        $recipients[] = $value['value'];
      }
      $value = implode(', ', $recipients);
      break;
  }
  return $value;
}