Created
June 16, 2016 13:11
-
-
Save alexpott/cbf40a3a0a4cd6a7c2331e8e8eb6a909 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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