You are here

class BasicAdvancedForm in Auth0 Single Sign On 8

Same name and namespace in other branches
  1. 8.2 src/Form/BasicAdvancedForm.php \Drupal\auth0\Form\BasicAdvancedForm

This forms handles the advanced module configurations.

Hierarchy

Expanded class hierarchy of BasicAdvancedForm

1 string reference to 'BasicAdvancedForm'
auth0.routing.yml in ./auth0.routing.yml
auth0.routing.yml

File

src/Form/BasicAdvancedForm.php, line 15
Contains \Drupal\auth0\Form\BasicAdvancedForm.

Namespace

Drupal\auth0\Form
View source
class BasicAdvancedForm extends FormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'auth0_basic_settings_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = \Drupal::service('config.factory')
      ->get('auth0.settings');
    $form['auth0_form_title'] = array(
      '#type' => 'textfield',
      '#title' => t('Form title'),
      '#default_value' => $config
        ->get('auth0_form_title', 'Sign In'),
      '#description' => t('This is the title for the login widget.'),
    );
    $form['auth0_allow_signup'] = array(
      '#type' => 'checkbox',
      '#title' => t('Allow user signup'),
      '#default_value' => $config
        ->get('auth0_allow_signup'),
      '#description' => t('If you have database connection you can allow users to signup in the widget.'),
    );
    $form['auth0_redirect_for_sso'] = array(
      '#type' => 'checkbox',
      '#title' => t('Redirect login for SSO'),
      '#default_value' => $config
        ->get('auth0_redirect_for_sso'),
      '#description' => t('If you are supporting SSO for your customers for other apps, including this application, click this to redirect to your Auth0 Hosted Login Page for Login and Signup'),
    );
    $form['auth0_widget_cdn'] = array(
      '#type' => 'textfield',
      '#title' => t('Widget CDN'),
      '#default_value' => $config
        ->get('auth0_widget_cdn'),
      '#description' => t('Point this to the latest widget available in the CDN.'),
    );
    $form['auth0_requires_verified_email'] = array(
      '#type' => 'checkbox',
      '#title' => t('Requires verified email'),
      '#default_value' => $config
        ->get('auth0_requires_verified_email'),
      '#description' => t('Mark this if you require the user to have a verified email to login.'),
    );
    $form['auth0_login_css'] = array(
      '#type' => 'textarea',
      '#title' => t('Login widget css'),
      '#default_value' => $config
        ->get('auth0_login_css'),
      '#description' => t('This css controls how the widget look and feel.'),
    );
    $form['auth0_lock_extra_settings'] = array(
      '#type' => 'textarea',
      '#title' => t('Lock extra settings'),
      '#default_value' => $config
        ->get('auth0_lock_extra_settings'),
      '#description' => t('This should be a valid JSON file. This entire object will be passed to the lock options parameter.'),
    );
    $form['actions']['#type'] = 'actions';
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => $this
        ->t('Save'),
      '#button_type' => 'primary',
    );
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $config = \Drupal::service('config.factory')
      ->getEditable('auth0.settings');
    $config
      ->set('auth0_form_title', $form_state
      ->getValue('auth0_form_title'))
      ->set('auth0_allow_signup', $form_state
      ->getValue('auth0_allow_signup'))
      ->set('auth0_redirect_for_sso', $form_state
      ->getValue('auth0_redirect_for_sso'))
      ->set('auth0_widget_cdn', $form_state
      ->getValue('auth0_widget_cdn'))
      ->set('auth0_requires_verified_email', $form_state
      ->getValue('auth0_requires_verified_email'))
      ->set('auth0_login_css', $form_state
      ->getValue('auth0_login_css'))
      ->set('auth0_lock_extra_settings', $form_state
      ->getValue('auth0_lock_extra_settings'))
      ->save();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BasicAdvancedForm::buildForm public function Form constructor. Overrides FormInterface::buildForm
BasicAdvancedForm::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
BasicAdvancedForm::submitForm public function Form submission handler. Overrides FormInterface::submitForm
BasicAdvancedForm::validateForm public function Form validation handler. Overrides FormBase::validateForm
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.
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.