Skip to content

Instantly share code, notes, and snippets.

@webflo
Created January 28, 2017 15:27
Show Gist options
  • Save webflo/f9d125b59ce5ab9e667542e878587625 to your computer and use it in GitHub Desktop.
Save webflo/f9d125b59ce5ab9e667542e878587625 to your computer and use it in GitHub Desktop.
/**
* Implements hook_install().
*
* Performs actions to set up the site for this profile.
*
* @see system_install()
*/
function blubb_install() {
global $config_directories;
$sync_directory = '../config/sync';
// Create a source storage that reads from sync.
$file_storage = new \Drupal\Core\Config\FileStorage($sync_directory);
// Match up the site uuids.
$system_site = $file_storage->read('system.site');
if (isset($system_site['uuid'])) {
\Drupal::configFactory()
->getEditable('system.site')
->set('uuid', $system_site['uuid'])
->save();
}
// Update settings.php.
$settings['config_directories']['sync'] = (object) [
'value' => $sync_directory,
'required' => TRUE,
];
drupal_rewrite_settings($settings);
$config_directories['sync'] = $sync_directory;
$languages = $file_storage->listAll('language.entity.');
foreach ($languages as $id) {
$language = $file_storage->read($id);
$config = \Drupal::configFactory()->getEditable($id);
$config->setData($language);
$config->save();
}
}
@webflo
Copy link
Author

webflo commented Jan 28, 2017

./vendor/bin/drush site-install --yes blubb --db-url="$SIMPLETEST_DB" --config-dir=$(pwd)/config/sync

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment