You are here

class LinkedinAuthSettingsForm in Social Auth LinkedIn 8

Same name and namespace in other branches
  1. 8.2 src/Form/LinkedInAuthSettingsForm.php \Drupal\social_auth_linkedin\Form\LinkedInAuthSettingsForm
  2. 3.x src/Form/LinkedInAuthSettingsForm.php \Drupal\social_auth_linkedin\Form\LinkedInAuthSettingsForm

Settings form for Social Auth Linkedin.

Hierarchy

  • class \Drupal\social_auth_linkedin\Form\LinkedinAuthSettingsForm extends \Drupal\social_auth\Form\SocialAuthSettingsForm

Expanded class hierarchy of LinkedinAuthSettingsForm

1 string reference to 'LinkedinAuthSettingsForm'
social_auth_linkedin.routing.yml in ./social_auth_linkedin.routing.yml
social_auth_linkedin.routing.yml

File

src/Form/LinkedinAuthSettingsForm.php, line 11

Namespace

Drupal\social_auth_linkedin\Form
View source
class LinkedinAuthSettingsForm extends SocialAuthSettingsForm {

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return array_merge([
      'social_auth_linkedin.settings',
    ], parent::getEditableConfigNames());
  }

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return '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,
    ];
    $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'),
    ];
    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'])
      ->save();
    parent::submitForm($form, $form_state);
  }

}

Members