function composer_manager_write_file in Composer Manager 6
Same name and namespace in other branches
- 6.2 composer_manager.module \composer_manager_write_file()
- 7.2 composer_manager.module \composer_manager_write_file()
- 7 composer_manager.module \composer_manager_write_file()
Writes the consolidated composer.json file for all modules that require third-party packages managed by Composer.
Return value
bool
3 calls to composer_manager_write_file()
- composer_manager_rebuild_form_submit in ./
composer_manager.admin.inc - Form submission handler for composer_manager_rebuild_form().
- composer_manager_write_if_changed in ./
composer_manager.module - Writes the composer.json file if one of the enabled / disabled modules has a composer.json file.
- drush_composer_manager_composer_json_rebuild in ./
composer_manager.drush.inc - Rebuilds the consolidated composer.json file.
File
- ./
composer_manager.module, line 179 - Provides consolidated management of third-party Composer-compatible packages required by contributed modules.
Code
function composer_manager_write_file() {
// Ensure only one process runs at a time. 10 seconds is more than enough.
// It is rare that a conflict will happen, and it isn't mission critical that
// we wait for the lock to release and regenerate the file again.
if (!lock_acquire(__FUNCTION__, 10)) {
return FALSE;
}
require_once __DIR__ . '/composer_manager.writer.inc';
try {
$data = composer_manager_fetch_data();
$json = composer_manager_build_json($data);
if ($json) {
$dir_uri = variable_get('composer_manager_file_dir', file_directory_path() . '/composer');
composer_manager_put_file($dir_uri, $json);
}
$success = TRUE;
} catch (\RuntimeException $e) {
$success = FALSE;
if (user_access('administer site configuration')) {
drupal_set_message(t('Error writing composer.json file'), 'error');
}
watchdog('composer_manager', $e
->getMessage(), array(), WATCHDOG_ERROR);
}
lock_release(__FUNCTION__);
return $success;
}