-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomposerplatformsupport.module
48 lines (43 loc) · 1.53 KB
/
composerplatformsupport.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* Implements hook_composer_json_alter().
*
* This hook filters out dependencies loaded by the skeleton project's
* composer.json files and its dependencies.
*
* @param $json
*/
function composerplatformsupport_composer_json_alter(&$json) {
// These are merged in composer_manager_build_json, except we don't need
// to filter repositories.
foreach (array('require', 'require-dev', 'conflict', 'replace', 'provide', 'suggest') as $key) {
foreach (\Composed\package_configs($key) as $config) {
// Remove already-installed packages from the JSON.
$json[$key] = array_diff_assoc((array) $json[$key], $config);
}
}
foreach (\Composed\package_configs('autoload') as $config) {
foreach ($config as $key => $value) {
$json['autoload'][$key] = array_diff_key((array) $json['autoload'][$key], $value);
}
}
// Remove empty autoload configurations.
$json['autoload'] = array_filter($json['autoload']);
$json = array_filter($json);
}
/**
* Implements hook_js_alter().
*/
function composerplatformsupport_js_alter(&$javascript) {
if (module_exists('statistics') &&
variable_get('statistics_count_content_views', 0) &&
variable_get('statistics_count_content_views_ajax', 0) &&
isset($javascript['settings'])) {
foreach ($javascript['settings']['data'] as &$js) {
if (isset($js['statistics'])
&& $js['statistics']['url'] === url(drupal_get_path('module', 'statistics') . '/statistics.php')) {
$js['statistics']['url'] = url('statistics.php');
}
}
}
}