public function ConfigImportForm::submitForm in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/config/src/Form/ConfigImportForm.php \Drupal\config\Form\ConfigImportForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- core/
modules/ config/ src/ Form/ ConfigImportForm.php, line 87 - Contains \Drupal\config\Form\ConfigImportForm.
Class
- ConfigImportForm
- Defines the configuration import form.
Namespace
Drupal\config\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
if ($path = $form_state
->getValue('import_tarball')) {
$this->configStorage
->deleteAll();
try {
$archiver = new ArchiveTar($path, 'gz');
$files = array();
foreach ($archiver
->listContent() as $file) {
$files[] = $file['filename'];
}
$archiver
->extractList($files, config_get_config_directory(CONFIG_SYNC_DIRECTORY));
drupal_set_message($this
->t('Your configuration files were successfully uploaded and are ready for import.'));
$form_state
->setRedirect('config.sync');
} catch (\Exception $e) {
drupal_set_message($this
->t('Could not extract the contents of the tar file. The error message is <em>@message</em>', array(
'@message' => $e
->getMessage(),
)), 'error');
}
drupal_unlink($path);
}
}