You are here

class Settings in OAuth2 Login 8

Hierarchy

Expanded class hierarchy of Settings

2 string references to 'Settings'
oauth2_login.routing.yml in ./oauth2_login.routing.yml
oauth2_login.routing.yml
oauth2_login.schema.yml in config/schema/oauth2_login.schema.yml
config/schema/oauth2_login.schema.yml

File

src/Form/Settings.php, line 8

Namespace

Drupal\oauth2_login\Form
View source
class Settings extends FormBase {
  public function getFormId() {
    return 'miniorange_oauth_client_settings';
  }

  /**
   * Showing Settings form.
   */
  public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state) {
    global $base_url;
    $baseUrlValue = \Drupal::config('oauth2_login.settings')
      ->get('miniorange_oauth_client_base_url');
    $attachments['#attached']['library'][] = 'oauth2_login/oauth2_login.admin';
    $form['markup_library'] = array(
      '#attached' => array(
        'library' => array(
          "oauth2_login/oauth2_login.admin",
          "oauth2_login/oauth2_login.style_settings",
          "oauth2_login/oauth2_login.slide_support_button",
        ),
      ),
    );
    $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_top_vt_start'] = array(
      '#markup' => '<b><h3>SIGN IN SETTINGS</h3></b><hr><br/>',
    );
    $form['miniorange_oauth_client_base_url'] = array(
      '#type' => 'textfield',
      '#title' => t('Base URL: '),
      '#default_value' => $baseUrlValue,
      '#attributes' => array(
        'id' => 'mo_oauth_vt_baseurl',
        'style' => 'width:73%;',
        'placeholder' => 'Enter Base URL',
      ),
      '#description' => '<b>Note: </b>You can change your base/site URL from here. (For eg: https://www.xyz.com or http://localhost/abc)',
      '#suffix' => '<br>',
    );
    $form['miniorange_oauth_client_siginin1'] = array(
      '#type' => 'submit',
      '#id' => 'button_config_center',
      '#value' => t('Update'),
      '#suffix' => '<br><hr>',
    );
    $form['miniorange_oauth_force_auth'] = array(
      '#type' => 'checkbox',
      '#title' => t('Protect website against anonymous access <a href="' . $base_url . '/admin/config/people/oauth2_login/licensing"><b>[Premium, Enterprise]</b></a>'),
      '#disabled' => TRUE,
      '#description' => t('<b>Note: </b>Users will be redirected to your OAuth server for login in case user is not logged in and tries to access website.<br><br>'),
    );
    $form['miniorange_oauth_auto_redirect'] = array(
      '#type' => 'checkbox',
      '#title' => t('Check this option if you want to <b> Auto-redirect to OAuth Provider/Server </b><a href="' . $base_url . '/admin/config/people/oauth2_login/licensing"><b>[Premium, Enterprise]</b></a>'),
      '#disabled' => TRUE,
      '#description' => t('<b>Note: </b>Users will be redirected to your OAuth server for login when the login page is accessed.<br><br>'),
    );
    $form['miniorange_oauth_enable_backdoor'] = array(
      '#type' => 'checkbox',
      '#title' => t('Check this option if you want to enable <b>backdoor login </b><a href="' . $base_url . '/admin/config/people/oauth2_login/licensing"><b>[Premium, Enterprise]</b></a>'),
      '#disabled' => TRUE,
      '#description' => t('<b>Note: </b>Checking this option creates a backdoor to login to your Website using Drupal credentials<br> incase you get locked out of your OAuth server.
                <b>Note down this URL: </b>Available in <a href="' . $base_url . '/admin/config/people/oauth2_login/licensing"><b>Premium, Enterprise</b></a> versions of the module.<br><br><br><br>'),
    );
    $form['markup_bottom_vt_start'] = array(
      '#markup' => '<hr><b><h3>DOMAIN & PAGE RESTRICTION</h3></b><hr><br/>',
    );
    $form['miniorange_oauth_client_white_list_url'] = array(
      '#type' => 'textfield',
      '#title' => t('Allowed Domains <a href="' . $base_url . '/admin/config/people/oauth2_login/licensing"><b>[Enterprise]</b></a>'),
      '#attributes' => array(
        'style' => 'width:73%',
        'placeholder' => 'Enter semicolon(;) separated domains (Eg. xxxx.com; xxxx.com)',
      ),
      '#description' => t('<b>Note: </b> Enter <b>semicolon(;) separated</b> domains to allow SSO. Other than these domains will not be allowed to do SSO.'),
      '#disabled' => TRUE,
    );
    $form['miniorange_oauth_client_black_list_url'] = array(
      '#type' => 'textfield',
      '#title' => t('Restricted Domains <a href="' . $base_url . '/admin/config/people/oauth2_login/licensing"><b>[Enterprise]</b></a>'),
      '#attributes' => array(
        'style' => 'width:73%',
        'placeholder' => 'Enter semicolon(;) separated domains (Eg. xxxx.com; xxxx.com)',
      ),
      '#description' => t('<b>Note: </b> Enter <b>semicolon(;) separated</b> domains to restrict SSO. Other than these domains will be allowed to do SSO.'),
      '#disabled' => TRUE,
    );
    $form['miniorange_oauth_client_page_restrict_url'] = array(
      '#type' => 'textfield',
      '#title' => t('Page Restriction <a href="' . $base_url . '/admin/config/people/oauth2_login/licensing"><b>[Enterprise]</b></a>'),
      '#attributes' => array(
        'style' => 'width:73%',
        'placeholder' => 'Enter semicolon(;) separated page URLs (Eg. xxxx.com/yyy; xxxx.com/yyy)',
      ),
      '#description' => t('<b>Note: </b> Enter <b>semicolon(;) separated</b> URLs to restrict unauthorized access.'),
      '#disabled' => TRUE,
    );
    $form['miniorange_oauth_client_siginin'] = array(
      '#type' => 'button',
      '#id' => 'button_config_center',
      '#disabled' => TRUE,
      '#value' => t('Save Configuration'),
    );
    $form['mo_header_style_end'] = array(
      '#markup' => '</div>',
    );
    Utilities::spConfigGuide($form, $form_state);
    $form['mo_markup_div_imp'] = array(
      '#markup' => '</div>',
    );
    Utilities::AddSupportButton($form, $form_state);
    return $form;
  }
  public function submitForm(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {
    $baseUrlvalue = trim($form['miniorange_oauth_client_base_url']['#value']);
    if (!empty($baseUrlvalue) && filter_var($baseUrlvalue, FILTER_VALIDATE_URL) == FALSE) {
      \Drupal::messenger()
        ->adderror(t('Please enter a valid URL'));
      return;
    }
    \Drupal::configFactory()
      ->getEditable('oauth2_login.settings')
      ->set('miniorange_oauth_client_base_url', $baseUrlvalue)
      ->save();
    \Drupal::messenger()
      ->addMessage(t('Configurations saved successfully.'));
  }

  /**
   * Send support query.
   */
  public function saved_support(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {
    $email = trim($form['miniorange_oauth_client_email_address']['#value']);
    $phone = trim($form['miniorange_oauth_client_phone_number']['#value']);
    $query = trim($form['miniorange_oauth_client_support_query']['#value']);
    Utilities::send_support_query($email, $phone, $query);
  }
  public function rfd(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {
    global $base_url;
    $response = new RedirectResponse($base_url . "/admin/config/people/oauth2_login/request_for_demo");
    $response
      ->send();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
FormBase::$configFactory protected property The config factory. 1
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::config protected function Retrieves a configuration object.
FormBase::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
FormBase::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create 87
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::redirect protected function Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait::redirect
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
FormBase::validateForm public function Form validation handler. Overrides FormInterface::validateForm 62
LinkGeneratorTrait::$linkGenerator protected property The link generator. 1
LinkGeneratorTrait::getLinkGenerator Deprecated protected function Returns the link generator.
LinkGeneratorTrait::l Deprecated protected function Renders a link to a route given a route name and its parameters.
LinkGeneratorTrait::setLinkGenerator Deprecated public function Sets the link generator service.
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
Settings::buildForm public function Showing Settings form. Overrides FormInterface::buildForm
Settings::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
Settings::rfd public function
Settings::saved_support public function Send support query.
Settings::submitForm public function Form submission handler. Overrides FormInterface::submitForm
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator Deprecated protected function Returns the URL generator service.
UrlGeneratorTrait::setUrlGenerator Deprecated public function Sets the URL generator service.
UrlGeneratorTrait::url Deprecated protected function Generates a URL or path for a specific route based on the given parameters.