class Settings in OAuth2 Login 8
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\oauth2_login\Form\Settings
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\FormView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Retrieves a configuration object. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
87 |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
FormBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
62 |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
Settings:: |
public | function |
Showing Settings form. Overrides FormInterface:: |
|
Settings:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
Settings:: |
public | function | ||
Settings:: |
public | function | Send support query. | |
Settings:: |
public | function |
Form submission handler. Overrides FormInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |