varbase_total_control.install in Varbase Total Control Dashboard 8.5
Same filename and directory in other branches
Install, update and uninstall functions for the Varbase Dahsboard module.
File
varbase_total_control.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the Varbase Dahsboard module.
*/
use Symfony\Component\Yaml\Yaml;
use Drupal\Core\Config;
use Drupal\Core\Config\InstallStorage;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Config\ExtensionInstallStorage;
use Drupal\Core\Config\FileStorage;
/**
* Implements hook_install().
*/
function varbase_total_control_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.
// ---------------------------------------------------------------------------
$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);
}
}
// 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, '');
}
// ---------------------------------------------------------------------------
}
Functions
Name![]() |
Description |
---|---|
varbase_total_control_install | Implements hook_install(). |