You are here

function varbase_install in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.6

Same name and namespace in other branches
  1. 8.8 varbase.install \varbase_install()
  2. 8.4 varbase.install \varbase_install()
  3. 8.5 varbase.install \varbase_install()
  4. 8.7 varbase.install \varbase_install()
  5. 7.3 varbase.install \varbase_install()
  6. 7 varbase.install \varbase_install()
  7. 7.2 varbase.install \varbase_install()
  8. 9.0.x varbase.install \varbase_install()

Implements hook_install().

Perform actions to set up the site for this profile.

See also

system_install()

File

./varbase.install, line 24
Install, update and uninstall functions for the Varbase installation profile.

Code

function varbase_install() {

  // Install optional configs.
  $config_installer = \Drupal::service('config.installer');
  $optional_install_path = drupal_get_path('profile', 'varbase') . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY;
  if (is_dir($optional_install_path)) {

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

    // Have the .settings.yml configs into the active config.
    $settings_config_files = file_scan_directory($optional_install_path, '/^.*(settings.yml)$/i');
    if (isset($settings_config_files) && is_array($settings_config_files)) {
      foreach ($settings_config_files as $settings_config_file) {
        $settings_config_file_content = file_get_contents(DRUPAL_ROOT . '/' . $settings_config_file->uri);
        $settings_config_file_data = (array) Yaml::parse($settings_config_file_content);
        $config_factory = \Drupal::configFactory()
          ->getEditable($settings_config_file->name);
        $config_factory
          ->setData($settings_config_file_data)
          ->save(TRUE);
      }
    }
  }

  // ---------------------------------------------------------------------------
  // Set front page to "node".
  \Drupal::configFactory()
    ->getEditable('system.site')
    ->set('page.front', '/node')
    ->save(TRUE);

  // Entity updates to clear up any mismatched entity and/or field definitions
  // And Fix changes were detected in the entity type and field definitions.
  \Drupal::classResolver()
    ->getInstanceFromDefinition(VarbaseEntityDefinitionUpdateManager::class)
    ->applyUpdates();

  // If Varbase Tour were enabled then redirect to the homepage with activ tour.
  if (isset($GLOBALS['homepage_with_varbase_tour']) && $GLOBALS['homepage_with_varbase_tour'] == TRUE) {
    $homepage_with_tour = "/?tour";
    $response = new Symfony\Component\HttpFoundation\RedirectResponse($homepage_with_tour);
    $response
      ->send();
    exit;
    include_once __DIR__ . '/../../core/includes/install.core.inc';
    include_once __DIR__ . '/../../core/includes/install.inc';
    install_goto('?tour');
  }
}