You are here

public function SimpleGateway::buildConfigurationForm in SMS simple gateway 8

Builds the configuration form.

Parameters

array $form: The configuration form.

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

Return value

array The updated form.

Overrides SmsGatewayPluginBase::buildConfigurationForm

File

src/Plugin/SmsGateway/SimpleGateway.php, line 97

Class

SimpleGateway
This plugin handles sending SMSes through most GET & POST based SMS Gateways.

Namespace

Drupal\sms_simplegateway\Plugin\SmsGateway

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildConfigurationForm($form, $form_state);
  $form['send'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Outgoing Messages'),
    '#tree' => TRUE,
    '#open' => TRUE,
  ];
  $form['send']['method'] = [
    '#type' => 'radios',
    '#required' => TRUE,
    '#title' => $this
      ->t('HTTP method'),
    '#default_value' => $this->configuration['method'],
    '#options' => [
      'get' => 'GET',
      'post' => 'POST',
    ],
  ];
  $form['send']['authorization'] = [
    '#type' => 'radios',
    '#required' => TRUE,
    '#title' => $this
      ->t('Authorization'),
    '#description' => $this
      ->t('For POST Requests Only. use "Username field value" & "Password field value" to specify credentials'),
    '#default_value' => $this->configuration['authorization'],
    '#options' => [
      'none' => 'NONE',
      'basic' => 'BASIC',
      'digest' => 'DIGEST',
      'ntlm' => 'NTLM',
    ],
  ];
  $form['send']['content_type'] = [
    '#type' => 'radios',
    '#required' => TRUE,
    '#title' => $this
      ->t('Content Encoding'),
    '#description' => $this
      ->t('For POST Requests Only.'),
    '#default_value' => $this->configuration['content_type'],
    '#options' => [
      'plain' => 'Plain',
      'json' => 'Json',
    ],
  ];
  $form['send']['base_url'] = [
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => $this
      ->t('Base URL for sending messages'),
    '#description' => $this
      ->t('Eg: http://simplegateway.example.com:13031/sendsms'),
    '#default_value' => $this->configuration['base_url'],
  ];
  $form['send']['user_field'] = [
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => $this
      ->t('Username field name'),
    '#description' => $this
      ->t('The argument/field name for the field that holds the username. Eg: user, username, authid.'),
    '#default_value' => $this->configuration['user_field'],
  ];
  $form['send']['user_value'] = [
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => $this
      ->t('Username field value'),
    '#description' => $this
      ->t('Your username for this gateway account.'),
    '#default_value' => $this->configuration['user_value'],
  ];
  $form['send']['pass_field'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Password field name'),
    '#description' => $this
      ->t('Optional. The argument/field name for the field that holds the password. Eg: pass, password, passwd.'),
    '#default_value' => $this->configuration['pass_field'],
  ];
  $form['send']['pass_value'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Password field value'),
    '#description' => $this
      ->t('Optional. Your password for this gateway account.'),
    '#default_value' => $this->configuration['pass_value'],
  ];
  $form['send']['sender_field'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Sender (from) field name'),
    '#description' => $this
      ->t('The argument/field name for the field that holds the sender number data. Eg: from, sender'),
    '#default_value' => $this->configuration['sender_field'],
  ];
  $form['send']['sender_value'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Sender (from) field value'),
    '#description' => $this
      ->t('The FROM number/name the sms should go out having'),
    '#default_value' => $this->configuration['sender_value'],
  ];
  $form['send']['number_field'] = [
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => $this
      ->t('Number (to) field name'),
    '#description' => $this
      ->t('The argument/field name for the field that holds the number data. Eg: number, to, no'),
    '#default_value' => $this->configuration['number_field'],
  ];
  $form['send']['number_prefix'] = [
    '#type' => 'textfield',
    '#title' => t('Number (to) prefix value'),
    '#description' => t('The value to be prefixed to the sender. Eg: country code'),
    '#default_value' => $this->configuration['number_prefix'],
  ];
  $form['send']['message_field'] = [
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => $this
      ->t('Message field name'),
    '#description' => $this
      ->t('The argument/field name for the field that holds the message text. Eg: message, text, content'),
    '#default_value' => $this->configuration['message_field'],
  ];
  $form['send']['extra_params'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Extra parameters'),
    '#description' => $this
      ->t('Any additional parameters that the gateway may need. Eg: route=4&country=0'),
    '#default_value' => $this->configuration['extra_params'],
  ];
  $form['receive']['receive_number_field'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Sender (from) field name'),
    '#description' => $this
      ->t('The argument/field name for the field that holds the sender number. Eg: sender, from.'),
    '#default_value' => $this->configuration['receive_number_field'],
    '#group' => 'incoming_messages',
  ];
  $form['receive']['receive_message_field'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Message field name'),
    '#description' => $this
      ->t('The argument/field name for the field that holds the message. Eg: message, text, content.'),
    '#default_value' => $this->configuration['receive_message_field'],
    '#group' => 'incoming_messages',
  ];
  $form['receive']['receive_gwnumber_field'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Receiver (to) field name'),
    '#description' => $this
      ->t('Optional. The argument/field name for the field that holds the gateway receiver number. Eg: to, inNumber, receiver.'),
    '#default_value' => $this->configuration['receive_gwnumber_field'],
    '#group' => 'incoming_messages',
  ];
  return $form;
}