You are here

function hook_composer_json_map_alter in Composer Manager 7.2

Allow modules to alter the JSON mappings.

Parameters

array $map: An associative array of key/value pairs, containing:

  • 'properties': (string[]|array[]) An indexed array of whitelisted property strings to be merged into the compiled Composer JSON file. If the specified property is an array, it will be treated a "parents" array to retrieve a nested value, see drupal_array_get_nested_value().
  • 'relative_paths': (array) An associative array of key/value pairs, containing:

    • 'keys': (string[]|array[]) An indexed array of property strings that will be iterated over to transform its keys into relative paths. If the specified property is an array, it will be treated a "parents" array to retrieve a nested value, see drupal_array_get_nested_value().
    • 'values': (string[]|array[]) An indexed array of property strings that will be iterated over to transform its values into relative paths. If the specified property is an array, it will be treated a "parents" array to retrieve a nested value, see drupal_array_get_nested_value().

See also

composer_manager_build_json()

1 invocation of hook_composer_json_map_alter()
composer_manager_build_json in ./composer_manager.writer.inc
Builds the JSON array containing the combined requirements of each module's composer.json file.

File

./composer_manager.api.php, line 45
Hooks provided by the Composer Manager module.

Code

function hook_composer_json_map_alter(array &$map) {

  // NOTE: the following code is just for example. These values are already
  // added to the JSON map by default and do not need to be specified again.
  // Whitelist a specific top level property.
  $map['properties'][] = 'config';

  // Whitelist a specific sub-property (e.g. not the whole "extra" property).
  $map['properties'][] = array(
    'extra',
    'installer-paths',
  );

  // Let composer manager know that a specific property keys are paths and
  // should be converted into relative paths from the generated Composer JSON.
  $map['relative_paths']['keys'][] = array(
    'extra',
    'installer-paths',
  );

  // Let composer manager know that a specific property values are paths and
  // should be converted into relative paths from the generated Composer JSON.
  $map['relative_paths']['values'][] = array(
    'extra',
    'patches',
  );
}