You are here

protected static function PetPreviewForm::callbackRecipients in Previewable email templates 8.3

Return an array of email recipients provided by a callback function.

@todo: test

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

Return value

array Recipient email addresses.

1 call to PetPreviewForm::callbackRecipients()
PetPreviewForm::validateRecipients in src/Form/PetPreviewForm.php
Validate existence of a non-empty recipient list free of email errors.

File

src/Form/PetPreviewForm.php, line 406

Class

PetPreviewForm
PetPreviewForm.

Namespace

Drupal\pet\Form

Code

protected static function callbackRecipients(FormStateInterface $form_state) {
  $callback = $form_state
    ->getValue('recipient_callback');
  if (!empty($callback)) {
    if (function_exists($callback)) {
      $recipients = $callback();

      // Remove uid for backward compatibility.
      if (isset($recipients) && is_array($recipients)) {
        return $recipients;
      }
    }
  }
  return [];
}