Skip to content

Instantly share code, notes, and snippets.

@alexpott
Created June 16, 2016 13:12
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexpott/74b72610c9870386ef88d97a73b3fc0c to your computer and use it in GitHub Desktop.
Save alexpott/74b72610c9870386ef88d97a73b3fc0c to your computer and use it in GitHub Desktop.
<?php
/**
* @file
* Install, update and uninstall functions for my project.
*/
/**
* Implements hook_install().
*
* Performs actions to set up the site for this profile.
*
* @see system_install()
*/
function my_project_install() {
global $config_directories;
$sync_directory = drupal_get_path('profile', 'my_project') . '/config/sync';
// Create a source storage that reads from sync.
$file_storage = new \Drupal\Core\Config\FileStorage(drupal_get_path('profile', 'my_project') . '/config/sync');
// 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'][CONFIG_SYNC_DIRECTORY] = (object) [
'value' => $sync_directory,
'required' => TRUE,
];
drupal_rewrite_settings($settings);
$config_directories[CONFIG_SYNC_DIRECTORY] = $sync_directory;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment