public static function ConfigurationManagement::importToActiveStoreFromTar in Configuration Management 7.2
Import configurations from a Tar file.
Parameters
StdClass $file: A file object.
boolean $start_tracking: If TRUE, all the configurations provided in the Tar file will be imported and automatically tracked.
Return value
ConfigIteratorSettings An ConfigIteratorSettings object that contains the imported configurations.
1 call to ConfigurationManagement::importToActiveStoreFromTar()
- configuration_ui_import_form_submit in ui/
configuration_ui.admin.inc - Submit handler for importing configs.
File
- lib/
Drupal/ configuration/ Config/ ConfigurationManagement.php, line 625 - Definition of Drupal\configuration\Config\ConfigurationManagement.
Class
Namespace
Drupal\configuration\ConfigCode
public static function importToActiveStoreFromTar($uri, $start_tracking = FALSE) {
$path = 'temporary://';
$archive = archiver_get_archiver($uri);
$files = $archive
->listContents();
foreach ($files as $filename) {
if (is_file($path . $filename)) {
file_unmanaged_delete($path . $filename);
}
}
$config_temp_path = 'temporary://' . 'config-tmp-' . time();
$archive
->extract(drupal_realpath($config_temp_path));
$file_content = drupal_substr(file_get_contents($config_temp_path . '/configuration/configurations.inc'), 6);
@eval($file_content);
$source = $config_temp_path . '/configuration/';
$modules_results = ConfigurationManagement::discoverRequiredModules($modules);
$missing_modules = $modules_results
->getInfo('modules_missing');
$error = FALSE;
if (!empty($missing_modules)) {
drupal_set_message(t('Configurations cannot be synchronized because the following modules are not available to install: %modules', array(
'%modules' => implode(', ', $missing_modules),
)), 'error');
return $modules_results;
}
else {
$modules_to_install = $modules_results
->getInfo('modules_to_install');
if (!empty($modules_to_install)) {
module_enable($modules_to_install, TRUE);
drupal_set_message(t('The following modules have been enabled: %modules', array(
'%modules' => implode(', ', $modules_to_install),
)));
drupal_flush_all_caches();
}
}
$settings = static::importToActiveStore($configurations, FALSE, FALSE, $start_tracking, $source);
static::deteleTempConfigDir($config_temp_path);
return $settings;
}