You are here

function varbase_auth_submit_formbit in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 9.0.x

Same name and namespace in other branches
  1. 8.8 src/FormBit/varbase_auth.formbit.php \varbase_auth_submit_formbit()
  2. 8.4 src/FormBit/varbase_auth.formbit.php \varbase_auth_submit_formbit()
  3. 8.5 src/FormBit/varbase_auth.formbit.php \varbase_auth_submit_formbit()
  4. 8.6 src/FormBit/varbase_auth.formbit.php \varbase_auth_submit_formbit()
  5. 8.7 src/FormBit/varbase_auth.formbit.php \varbase_auth_submit_formbit()

Submit form bit with editable config values.

To update the editable config in drupal active config.

Parameters

array $editable_config_values: Editable cofnig values.

File

src/FormBit/varbase_auth.formbit.php, line 58
FormBit file for varbase_auth feature mdoule.

Code

function varbase_auth_submit_formbit(array $editable_config_values) {
  $configFactory = \Drupal::configFactory()
    ->getEditable('simple.settings');
  $configFactory
    ->set('social_auth_type', $editable_config_values['simple.settings']['social_auth_type']);
  $configFactory
    ->save(TRUE);

  // From the Config and enable the modules.
  $auth_modules = $configFactory
    ->get('social_auth_type');
  if (isset($auth_modules) && is_array($auth_modules) && count($auth_modules) > 0) {
    $modules_to_install = [];
    foreach ($auth_modules as $auth_module) {
      if (is_string($auth_module)) {
        array_push($modules_to_install, $auth_module);
      }
    }
    if (isset($modules_to_install) && is_array($modules_to_install) && count($modules_to_install) > 0) {
      \Drupal::service('module_installer')
        ->install($modules_to_install);
    }
  }
}