コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     global $config_directories, $install_state;
     $sync_directory = $form_state->getValue('sync_directory');
     if ($sync_directory != config_get_config_directory(CONFIG_SYNC_DIRECTORY)) {
         $settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) array('value' => $sync_directory, 'required' => TRUE);
         drupal_rewrite_settings($settings);
         $config_directories[CONFIG_SYNC_DIRECTORY] = $sync_directory;
     }
     if ($path = $form_state->getValue('import_tarball')) {
         // Ensure that we have an empty directory if we're going.
         $sync = new FileStorage($sync_directory);
         $sync->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, ready for import.'));
         } 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);
     }
     // Change the langcode to the site default langcode provided by the
     // configuration.
     $config_storage = new FileStorage(config_get_config_directory(CONFIG_SYNC_DIRECTORY));
     $install_state['parameters']['langcode'] = $config_storage->read('system.site')['langcode'];
 }