Commit 0fb0777c authored by Rajab Natshah's avatar Rajab Natshah
Browse files

Issue #3272298: Switch to use the Module Installer Factory in the Varbase...

Issue #3272298: Switch to use the Module Installer Factory in the Varbase Social Single Sign-On module
parent 0c5098c9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
    "oomphinc/composer-installers-extender": "~1.0 || ~2.0",
    "cweagans/composer-patches": "~1.0",
    "drupal/core": "~9.0",
    "vardot/module-installer-factory": "~1.0",
    "drupal/social_api": "~3.0",
    "drupal/social_auth": "~3.0",
    "drupal/social_auth_google": "~3.0",
+3 −27
Original line number Diff line number Diff line
@@ -5,41 +5,17 @@
 * Install, update and uninstall functions for the varbase auth module.
 */

use Symfony\Component\Yaml\Yaml;
use Drupal\Core\Config\InstallStorage;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Config\FileStorage;
use Vardot\Installer\ModuleInstallerFactory;

/**
 * Implements hook_install().
 */
function varbase_auth_install() {

  $module_name = preg_replace('/_install$/', '', __FUNCTION__);
  $module_path = Drupal::service('module_handler')->getModule($module_name)->getPath();

  // Processer for install: in [$module_name].info.yml file.
  // Processer for install: in varbase_auth.info.yml file.
  // ---------------------------------------------------------------------------.
  $module_info_file = $module_path . '/' . $module_name . '.info.yml';
  if (file_exists($module_info_file)) {
    $module_info_data = (array) Yaml::parse(file_get_contents($module_info_file));
    if (isset($module_info_data['install'])
      && is_array($module_info_data['install'])) {
      \Drupal::service('module_installer')->install($module_info_data['install'], TRUE);
    }
  }
  ModuleInstallerFactory::installList('varbase_auth');

  // Install optional configs.
  $optional_install_path = $module_path . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY;
  if (is_dir($optional_install_path)) {
    $config_installer = \Drupal::service('config.installer');
    $config_installer->installDefaultConfig('module', $module_name);

    // Install any optional config the module provides.
    $storage = new FileStorage($optional_install_path, StorageInterface::DEFAULT_COLLECTION);
    $config_installer->installOptionalConfig($storage, '');

  }
}

/**