You are here

function composer_manager_write_if_changed in Composer Manager 6.2

Same name and namespace in other branches
  1. 6 composer_manager.module \composer_manager_write_if_changed()
  2. 7.2 composer_manager.module \composer_manager_write_if_changed()
  3. 7 composer_manager.module \composer_manager_write_if_changed()

Writes the composer.json file if one of the enabled / disabled modules has a composer.json file.

This is a primitive check to ensure that the composer.json file is built only when it has changes. This check always passes when run via the command line, as it is assumed that Drush is being used to enable or disable the the modules. A static boolean is also set flagging whether one or more modules being acted on contains a composer.json file, which is used in Drush hooks.

Parameters

array $modules: The enabled / disabled modules being scanned for a composer.json file.

2 calls to composer_manager_write_if_changed()
composer_manager_enable in ./composer_manager.install
Implements hook_enable().
composer_manager_system_modules_submit in ./composer_manager.module
Form submission handler for system_modules().
1 string reference to 'composer_manager_write_if_changed'
drush_composer_manager_write_if_changed in ./composer_manager.drush.inc
If one or more extensions being acted on contain a composer.json file, prompt the user to automatically run Composer's update command.

File

./composer_manager.module, line 96
Provides consolidated management of third-party Composer-compatible packages required by contributed modules.

Code

function composer_manager_write_if_changed(array $modules) {
  $changed =& composer_manager_static(__FUNCTION__, FALSE);
  if (variable_get('composer_manager_autobuild_file', 1) || drupal_is_cli()) {
    if (composer_manager_packages_have_changed($modules)) {
      $changed = TRUE;
      composer_manager_write_file();
    }
  }
}