You are here

public function TwilioAdminTestForm::submitForm in Twilio 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

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

Overrides FormInterface::submitForm

File

src/Form/TwilioAdminTestForm.php, line 96

Class

TwilioAdminTestForm
Form to send test SMS messages.

Namespace

Drupal\twilio\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $message = [];
  $message['body'] = $form_state
    ->getValue('message') ? $form_state
    ->getValue('message') : '';
  if ($mediaUrl = $form_state
    ->getValue('mediaUrl')) {
    $message['mediaUrl'] = $mediaUrl;
  }
  $number = '+' . $form_state
    ->getValue([
    'country',
  ]) . $form_state
    ->getValue([
    'number',
  ]);
  $this->command
    ->messageSend($number, $message);
  $this
    ->messenger()
    ->addStatus($this
    ->t('Attempted to send SMS message. Check your receiving device.'));
}