You are here

class JanrainCaptureSettingsForm in Janrain Registration 8

Janrain Capture settings form.

Hierarchy

Expanded class hierarchy of JanrainCaptureSettingsForm

1 string reference to 'JanrainCaptureSettingsForm'
janrain_capture.routing.yml in ./janrain_capture.routing.yml
janrain_capture.routing.yml

File

src/Form/JanrainCaptureSettingsForm.php, line 11

Namespace

Drupal\janrain_capture\Form
View source
class JanrainCaptureSettingsForm extends ConfigFormBase {

  /**
   * The list of identity providers for social login.
   */
  protected const SOCIAL_IDENTITY_PROVIDERS = [
    'amazon' => 'Amazon',
    'aol' => 'AOL',
    'blogger' => 'Blogger',
    'disqus' => 'Disqus',
    'doccheck' => 'DocCheck',
    'doximity' => 'Doximity',
    'facebook' => 'Facebook',
    'flickr' => 'Flickr',
    'fimnet' => 'Fimnet',
    'foursquare' => 'Foursquare',
    'googleplus' => 'Google+',
    'instagram' => 'Instagram',
    'linkedin' => 'LinkedIn',
    'livejournal' => 'LiveJournal',
    'medikey' => 'MediKey',
    'medy' => 'Medy',
    'microsoftaccount' => 'Microsoft Account',
    'mixi' => 'Mixi',
    'mydigipass' => 'MYDIGIPASS.COM',
    'odnoklassniki' => 'Odnoklassniki',
    'onekey' => 'OneKey',
    'openid' => 'OpenID',
    'paypal' => 'PayPal',
    'qq' => 'QQ',
    'renren' => 'Renren',
    'salesforce' => 'Salesforce',
    'sina weibo' => 'Sina Weibo',
    'soundcloud' => 'SoundCloud',
    'tumblr' => 'Tumblr',
    'twitter' => 'Twitter',
    'vk' => 'VK',
    'wechat' => 'WeChat',
    'xing' => 'Xing',
    'yahoo' => 'Yahoo!',
  ];

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return [
      'janrain_capture.settings',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'janrain_capture.settings.capture';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildForm($form, $form_state);
    $config = $this
      ->config('janrain_capture.settings');
    $form['capture'] = [
      '#type' => 'fieldset',
      '#tree' => TRUE,
      '#title' => $this
        ->t('Janrain Capture settings'),
    ];
    $form['capture']['app_id'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Application ID'),
      '#description' => $this
        ->t('The Capture application ID that represents a specific capture app.'),
      '#default_value' => $config
        ->get('capture.app_id'),
    ];
    $form['capture']['client_id'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Client ID'),
      '#description' => $this
        ->t('A client ID from your Registration application.'),
      '#default_value' => $config
        ->get('capture.client_id'),
    ];
    $form['capture']['client_secret'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Client Secret'),
      '#description' => $this
        ->t('A client secret from your Registration application'),
      '#default_value' => $config
        ->get('capture.client_secret'),
    ];
    $form['capture']['load_js_url'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Load.js file URL'),
      '#description' => $this
        ->t('Application load file (load.js)'),
      '#default_value' => $config
        ->get('capture.load_js_url'),
    ];
    $form['capture']['capture_server'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Capture server URL'),
      '#description' => $this
        ->t('The URL of the server hosting the Registration application.For example, https://myapp.janraincapture.com.'),
      '#default_value' => $config
        ->get('capture.capture_server'),
    ];
    $form['capture']['providers'] = [
      '#type' => 'details',
      '#open' => FALSE,
      '#title' => $this
        ->t('Social login'),
      '#collapsible' => TRUE,
      '#description' => $this
        ->t('Social login enables users to register on your web site by using an account created with a third-party identity provider (IDP). Read more in the <a href="@documentation">official documentation</a>.', [
        '@documentation' => 'https://docs.janrain.com/social/identity-providers',
      ]),
    ];
    $form['capture']['providers']['list'] = [
      '#type' => 'checkboxes',
      '#title' => $this
        ->t('Identity providers'),
      '#options' => static::SOCIAL_IDENTITY_PROVIDERS,
      '#default_value' => $config
        ->get('capture.providers'),
    ];
    $form['capture']['engage'] = [
      '#type' => 'details',
      '#open' => FALSE,
      '#title' => $this
        ->t('Engage Settings (optional)'),
      '#collapsible' => TRUE,
    ];
    $form['capture']['engage']['app_url'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Engage App URL'),
      '#description' => $this
        ->t('The URL of the Janrain Engage Single Sign-on server. For example, myapp.rpxnow.com.'),
      '#default_value' => $config
        ->get('capture.app_url'),
    ];
    $form['capture']['engage']['token_action'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Engage Token Action'),
      '#description' => $this
        ->t('The Token Action of the Janrain Engage Single Sign-on server. For example, "event".'),
      '#default_value' => $config
        ->get('capture.token_action'),
    ];
    $form['capture']['federate'] = [
      '#type' => 'details',
      '#title' => $this
        ->t('Federate Settings (optional)'),
      '#collapsible' => TRUE,
      '#open' => $config
        ->get('capture.enable_sso'),
    ];
    $form['capture']['federate']['enable_sso'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable SSO'),
      '#description' => $this
        ->t('Enable Single Sign On.'),
      '#default_value' => $config
        ->get('capture.enable_sso'),
    ];
    $form['capture']['federate']['federate_server'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Federate Server'),
      '#description' => $this
        ->t('The URL of the Janrain Single Sign-on server. For example, myapp.janrainsso.com.'),
      '#default_value' => $config
        ->get('capture.federate_server'),
    ];
    $form['capture']['federate']['federate_segment'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Federate segment'),
      '#description' => $this
        ->t('Specifies which SSO segment the current property belongs in.'),
      '#default_value' => $config
        ->get('capture.federate_segment'),
    ];
    $form['capture']['federate']['federate_supported_segments'] = [
      '#type' => 'textarea',
      '#title' => $this
        ->t('SSO Supported Segment Names'),
      '#default_value' => $config
        ->get('capture.federate_supported_segments'),
      '#description' => $this
        ->t('Segments that the current site is allowed to federate with using Single Sign-on.'),
    ];
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);
    $capture = $form_state
      ->getValue('capture');
    $this->configFactory
      ->getEditable('janrain_capture.settings')
      ->set('capture.app_id', $capture['app_id'])
      ->set('capture.client_id', $capture['client_id'])
      ->set('capture.client_secret', $capture['client_secret'])
      ->set('capture.load_js_url', $capture['load_js_url'])
      ->set('capture.providers', array_keys(array_filter($capture['providers']['list'])))
      ->set('capture.capture_server', $capture['capture_server'])
      ->set('capture.app_url', $capture['engage']['app_url'])
      ->set('capture.token_action', $capture['engage']['token_action'])
      ->set('capture.enable_sso', $capture['federate']['enable_sso'])
      ->set('capture.federate_server', $capture['federate']['federate_server'])
      ->set('capture.federate_segment', $capture['federate']['federate_segment'])
      ->set('capture.federate_supported_segments', $capture['federate']['federate_supported_segments'])
      ->save();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigFormBase::create public static function Instantiates a new instance of this class. Overrides FormBase::create 13
ConfigFormBase::__construct public function Constructs a \Drupal\system\ConfigFormBase object. 11
ConfigFormBaseTrait::config protected function Retrieves a configuration object.
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::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
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
JanrainCaptureSettingsForm::buildForm public function Form constructor. Overrides ConfigFormBase::buildForm
JanrainCaptureSettingsForm::getEditableConfigNames protected function Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait::getEditableConfigNames
JanrainCaptureSettingsForm::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
JanrainCaptureSettingsForm::SOCIAL_IDENTITY_PROVIDERS protected constant The list of identity providers for social login.
JanrainCaptureSettingsForm::submitForm public function Form submission handler. Overrides ConfigFormBase::submitForm
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.
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.