You are here

public static function Utilities::send_demo_query in Drupal OAuth & OpenID Connect Login - OAuth2 Client SSO Login 8

2 calls to Utilities::send_demo_query()
MiniorangeLicensing::send_rfd_query in src/Form/MiniorangeLicensing.php
MiniorangeRFD::submitForm in src/Form/MiniorangeRFD.php
Form submission handler.

File

src/Utilities.php, line 202

Class

Utilities

Namespace

Drupal\miniorange_oauth_client

Code

public static function send_demo_query($email, $query, $description) {
  if (empty($email) || empty($description)) {
    \Drupal::messenger()
      ->addMessage(t('The <b><u>Email</u></b> and <b><u>Description</u></b> fields are mandatory.'), 'error');
    return;
  }
  elseif (!\Drupal::service('email.validator')
    ->isValid($email)) {
    \Drupal::messenger()
      ->addMessage(t('The email address <b><i>' . $email . '</i></b> is not valid.'), 'error');
    return;
  }
  $phone = \Drupal::config('miniorange_oauth_client.settings')
    ->get('miniorange_oauth_client_customer_admin_phone');
  $support = new MiniorangeOAuthClientSupport($email, $phone, $query, 'demo');
  $support_response = $support
    ->sendSupportQuery();
  if ($support_response) {
    \Drupal::messenger()
      ->addMessage(t('Demo request query successfully sent. We will get back to you shortly.'), 'status');
  }
  else {
    \Drupal::messenger()
      ->addMessage(t('Error sending demo request query'), 'error');
  }
}