class LinkedInAuthSettingsForm in Social Auth LinkedIn 3.x
Same name and namespace in other branches
- 8.2 src/Form/LinkedInAuthSettingsForm.php \Drupal\social_auth_linkedin\Form\LinkedInAuthSettingsForm
- 8 src/Form/LinkedinAuthSettingsForm.php \Drupal\social_auth_linkedin\Form\LinkedinAuthSettingsForm
Settings form for Social Auth LinkedIn.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, RedirectDestinationTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\social_auth\Form\SocialAuthSettingsForm
- class \Drupal\social_auth_linkedin\Form\LinkedInAuthSettingsForm
- class \Drupal\social_auth\Form\SocialAuthSettingsForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of LinkedInAuthSettingsForm
1 string reference to 'LinkedInAuthSettingsForm'
File
- src/
Form/ LinkedInAuthSettingsForm.php, line 12
Namespace
Drupal\social_auth_linkedin\FormView source
class LinkedInAuthSettingsForm extends SocialAuthSettingsForm {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'social_auth_linkedin_settings';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return array_merge(parent::getEditableConfigNames(), [
'social_auth_linkedin.settings',
]);
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('social_auth_linkedin.settings');
$form['linkedin_settings'] = [
'#type' => 'details',
'#title' => $this
->t('LinkedIn Client settings'),
'#open' => TRUE,
'#description' => $this
->t('You need to first create a LinkedIn App at <a href=":linkedin-dev">:linkedin-dev</a>', [
'@linkedin-dev' => 'https://www.linkedin.com/secure/developer',
]),
];
$form['linkedin_settings']['client_id'] = [
'#type' => 'textfield',
'#required' => TRUE,
'#title' => $this
->t('Client ID'),
'#default_value' => $config
->get('client_id'),
'#description' => $this
->t('Copy the Client ID here.'),
];
$form['linkedin_settings']['client_secret'] = [
'#type' => 'textfield',
'#required' => TRUE,
'#title' => $this
->t('Client Secret'),
'#default_value' => $config
->get('client_secret'),
'#description' => $this
->t('Copy the Client Secret here.'),
];
$form['linkedin_settings']['authorized_redirect_url'] = [
'#type' => 'textfield',
'#disabled' => TRUE,
'#title' => $this
->t('Authorized redirect URL'),
'#description' => $this
->t('Copy this value to <em>Authorized Redirect URLs</em> field of your LinkedIn App settings.'),
'#default_value' => Url::fromRoute('social_auth_linkedin.callback')
->setAbsolute()
->toString(),
];
$form['linkedin_settings']['advanced'] = [
'#type' => 'details',
'#title' => $this
->t('Advanced settings'),
'#open' => FALSE,
];
$form['linkedin_settings']['advanced']['scopes'] = [
'#type' => 'textarea',
'#title' => $this
->t('Scopes for API call'),
'#default_value' => $config
->get('scopes'),
'#description' => $this
->t('Define any additional scopes to be requested, separated by a comma (e.g.: r_1st_connections,w_member_social).<br>
The scopes \'r_liteprofile\' and \'r_emailaddress\' are added by default and always requested.<br>
You can see the full list of valid fields and required scopes <a href="@fields">here</a>.', [
'@fields' => 'https://docs.microsoft.com/en-us/linkedin/consumer/',
]),
];
$form['linkedin_settings']['advanced']['endpoints'] = [
'#type' => 'textarea',
'#title' => $this
->t('API calls to be made to collect data'),
'#default_value' => $config
->get('endpoints'),
'#description' => $this
->t('Define the endpoints to be requested when user authenticates with LinkedIn for the first time<br>
Enter each endpoint in different lines in the format <em>endpoint</em>|<em>name_of_endpoint</em>.<br>
<b>For instance:</b><br>
/v2/me|profile'),
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
$this
->config('social_auth_linkedin.settings')
->set('client_id', $values['client_id'])
->set('client_secret', $values['client_secret'])
->set('scopes', $values['scopes'])
->set('endpoints', $values['endpoints'])
->save();
parent::submitForm($form, $form_state);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 3 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 3 |
FormBase:: |
private | function | Returns the service container. | |
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. | |
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. | |
LinkedInAuthSettingsForm:: |
public | function |
Form constructor. Overrides SocialAuthSettingsForm:: |
|
LinkedInAuthSettingsForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides SocialAuthSettingsForm:: |
|
LinkedInAuthSettingsForm:: |
public | function |
Returns a unique string identifying the form. Overrides SocialAuthSettingsForm:: |
|
LinkedInAuthSettingsForm:: |
public | function |
Form submission handler. Overrides SocialAuthSettingsForm:: |
|
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. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
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. | |
SocialAuthSettingsForm:: |
protected | property | The route provider. | |
SocialAuthSettingsForm:: |
public static | function |
Instantiates a new instance of this class. Overrides ConfigFormBase:: |
|
SocialAuthSettingsForm:: |
public | function |
Form validation handler. Overrides FormBase:: |
|
SocialAuthSettingsForm:: |
public | function |
Constructor. Overrides ConfigFormBase:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
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. |