function configuration_sync_configurations_submit in Configuration Management 7.2
1 string reference to 'configuration_sync_configurations_submit'
- configuration_ui_sync_form in ui/
configuration_ui.admin.inc - Menu Callback Form.
File
- ui/
configuration_ui.admin.inc, line 687 - User interface functions for Configuration Management.
Code
function configuration_sync_configurations_submit($form, &$form_state) {
$tracking_file = ConfigurationManagement::readTrackingFile();
if (empty($tracking_file)) {
$path = drupal_realpath(ConfigurationManagement::getStream());
drupal_set_message(t('The Tracking file is not present. The synchronization can not be performed.'), 'error');
return FALSE;
}
$to_track = array_keys($tracking_file['tracked']);
$modules_results = ConfigurationManagement::discoverRequiredModules($tracking_file['modules']);
$missing_modules = $modules_results
->getInfo('missing_modules');
if (!empty($missing_modules)) {
drupal_set_message(t('Configurations cannot be synchronized because the following modules are not available to install: %modules', array(
'%modules' => implode(', ', $missing_modules),
)), 'error');
$error = TRUE;
}
else {
$modules_to_install = $modules_results
->getInfo('modules_to_install');
drupal_set_message(t('The following will be enabled: %modules', array(
'%modules' => implode(', ', $modules_to_install),
)));
if (!empty($modules_to_install)) {
module_enable($modules_to_install, TRUE);
drupal_set_message(t('The following modules have been enabled: %modules', array(
'%modules' => implode(', ', $modules_to_install),
)));
}
}
// If we have to stop stracking some configurations, figure out which
// configurations have to be untracked.
if (empty($form_state['values']['preserve_tracked'])) {
$being_tracked = array_keys(ConfigurationManagement::trackedConfigurations(FALSE));
$to_untrack = array_diff($being_tracked, $to_track);
$un_track_results = ConfigurationManagement::stopTracking($to_untrack, TRUE, TRUE);
if (count($un_track_results
->getInfo('untracked'))) {
foreach ($un_track_results
->getInfo('untracked') as $untracked_config) {
drupal_set_message(t('Untracked %config', array(
'%config' => $untracked_config,
)));
}
}
}
$include_dependencies = $form_state['values']['include_dependencies'];
$include_optionals = $form_state['values']['include_optionals'];
$results = ConfigurationManagement::importToActiveStore($to_track, $include_dependencies, $include_optionals, TRUE);
foreach ($results
->getInfo('imported') as $imported) {
drupal_set_message(t('Imported %config', array(
'%config' => $imported,
)));
}
foreach ($results
->getInfo('no_handler') as $failed) {
drupal_set_message(t('%config could be imported because there is no module that can handle that configuration.', array(
'%config' => $failed,
)));
}
}