You are here

public function MiniorangeOAuthClientCustomerSetup::buildForm in OAuth2 Login 8

Form constructor.

Parameters

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

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

Return value

array The form structure.

Overrides FormInterface::buildForm

File

src/Form/MiniorangeOAuthClientCustomerSetup.php, line 22
Contains \Drupal\miniorange_oauth_client\Form\MiniorangeOAuthClientCustomerSetup.

Class

MiniorangeOAuthClientCustomerSetup

Namespace

Drupal\oauth2_login\Form

Code

public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state) {
  global $base_url;
  $current_status = \Drupal::config('oauth2_login.settings')
    ->get('miniorange_oauth_client_status');
  $form['markup_library'] = array(
    '#attached' => array(
      'library' => array(
        "oauth2_login/oauth2_login.admin",
        "oauth2_login/oauth2_login.style_settings",
        "oauth2_login/oauth2_login.module",
        "oauth2_login/oauth2_login.slide_support_button",
      ),
    ),
  );
  if ($current_status == 'VALIDATE_OTP') {
    $form['header_top_style_1'] = array(
      '#markup' => '<div class="mo_oauth_table_layout_1">',
    );
    $form['markup_top'] = array(
      '#markup' => '<div class="mo_oauth_table_layout mo_oauth_container">',
    );
    $form['miniorange_oauth_client_customer_otp_token'] = array(
      '#type' => 'textfield',
      '#title' => t('OTP'),
      '#attributes' => array(
        'style' => 'width:30%;',
      ),
    );
    $form['mo_btn_brk'] = array(
      '#markup' => '<br><br>',
    );
    $form['miniorange_oauth_client_customer_validate_otp_button'] = array(
      '#type' => 'submit',
      '#value' => t('Validate OTP'),
      '#submit' => array(
        '::miniorange_oauth_client_validate_otp_submit',
      ),
    );
    $form['miniorange_oauth_client_customer_setup_resendotp'] = array(
      '#type' => 'submit',
      '#value' => t('Resend OTP'),
      '#submit' => array(
        '::miniorange_oauth_client_resend_otp',
      ),
    );
    $form['miniorange_oauth_client_customer_setup_back'] = array(
      '#type' => 'submit',
      '#value' => t('Back'),
      '#submit' => array(
        '::miniorange_oauth_client_back',
      ),
    );
    $form['header_top_div_end'] = array(
      '#markup' => '</div></div>',
    );
    Utilities::AddSupportButton($form, $form_state);
    return $form;
  }
  elseif ($current_status == 'PLUGIN_CONFIGURATION') {
    $form['header_top_style_1'] = array(
      '#markup' => '<div class="mo_oauth_table_layout_1">',
    );
    $form['markup_top'] = array(
      '#markup' => '<div class="mo_oauth_table_layout mo_oauth_container">',
    );
    $form['mo_message_wlcm'] = array(
      '#markup' => '<div class="mo_oauth_client_welcome_message">Thank you for registering with miniOrange',
    );
    $form['mo_user_profile'] = array(
      '#markup' => '</div><br><br><h4>Your Profile: </h4>',
    );
    $header = array(
      'email' => array(
        'data' => t('Customer Email'),
      ),
      'customerid' => array(
        'data' => t('Customer ID'),
      ),
      'token' => array(
        'data' => t('Token Key'),
      ),
      'apikey' => array(
        'data' => t('API Key'),
      ),
    );
    $options = [];
    $options[0] = array(
      'email' => \Drupal::config('oauth2_login.settings')
        ->get('miniorange_oauth_client_customer_admin_email'),
      'customerid' => \Drupal::config('oauth2_login.settings')
        ->get('miniorange_oauth_client_customer_id'),
      'token' => \Drupal::config('oauth2_login.settings')
        ->get('miniorange_oauth_client_customer_admin_token'),
      'apikey' => \Drupal::config('oauth2_login.settings')
        ->get('miniorange_oauth_client_customer_api_key'),
    );
    $form['fieldset']['customerinfo'] = array(
      '#theme' => 'table',
      '#header' => $header,
      '#rows' => $options,
    );
    $form['miniorange_oauth_client_support_div_cust'] = array(
      '#markup' => '<br><br><br><br></div>',
    );
    Utilities::spConfigGuide($form, $form_state);
    $form['mo_markup_div_end2'] = array(
      '#markup' => '</div>',
    );
    Utilities::AddSupportButton($form, $form_state);
    return $form;
  }
  $form['header_top_style_1'] = array(
    '#markup' => '<div class="mo_oauth_table_layout_1">',
  );
  $form['markup_top'] = array(
    '#markup' => '<div class="mo_oauth_table_layout mo_oauth_container">',
  );
  $form['markup_14'] = array(
    '#markup' => '<h3>Register/Login with miniOrange</h3><hr><br>',
  );
  $form['markup_2'] = array(
    '#markup' => '<div class="mo_oauth_highlight_background_note_export"><p><h3>Why Should I register?</h3></p>
            <b> You will be needing a miniOrange account to upgrade to the Standard, Premium or Enterprise versions of the modules.</b>
             If you face any problem during registration, you can create an account by clicking <a href="https://www.miniorange.com/businessfreetrial" target="_blank">here.</a><br>
             We do not store any information except the email that you will use to register with us.<br></div><br>',
  );
  $form['miniorange_oauth_client_customer_setup_username'] = array(
    '#type' => 'textfield',
    '#title' => t('Email'),
    '#attributes' => array(
      'style' => 'width:50%;',
      'placeholder' => 'Enter your email',
    ),
    '#required' => TRUE,
  );
  $form['miniorange_oauth_client_customer_setup_phone'] = array(
    '#type' => 'textfield',
    '#title' => t('Phone'),
    '#attributes' => array(
      'style' => 'width:50%;',
    ),
    '#description' => '<b>NOTE:</b> We will only call if you need support.',
  );
  $form['miniorange_oauth_client_customer_setup_password'] = array(
    '#type' => 'password_confirm',
    '#required' => TRUE,
  );
  $form['miniorange_oauth_client_customer_setup_button'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
    '#id' => 'button_config',
  );
  $form['markup_divEnd'] = array(
    '#markup' => '</div>',
  );
  Utilities::spConfigGuide($form, $form_state);
  $form['mo_markup_div_end'] = array(
    '#markup' => '</div>',
  );
  Utilities::AddSupportButton($form, $form_state);
  return $form;
}