forked from drupalprojects/hosting_varnish
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhosting_varnish.drush.inc
More file actions
43 lines (36 loc) · 1.26 KB
/
hosting_varnish.drush.inc
File metadata and controls
43 lines (36 loc) · 1.26 KB
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
<?php
/**
* implementation of the hosting_post_install hook
*/
function hosting_varnish_post_hosting_install_task($task, $data) {
if ($task->ref->type == 'site') {
$hosting_name = $task->ref->hosting_name;
$cache_vars = array(
'cache',
'block_cache',
'cache_lifetime',
'page_cache_maximum_age',
'page_compression',
'preprocess_css',
'preprocess_js',
);
$active = variable_get('hosting_varnish_active' . '_' . $task->ref->platform, NULL);
if ($active != TRUE) {
drush_log('Automatic cache settings not activated for this platform, moving on.');
return;
}
drush_log('Enabling cache settings for ' . $hosting_name);
// Iterate over possible variables and set them in the site
foreach ($cache_vars as $varname) {
$hosting_varnish_varname = 'hosting_varnish_' . $varname . '_' . $task->ref->platform;
$value = variable_get($hosting_varnish_varname, NULL);
if ($value !== NULL) {
drush_log('[hosting_varnish] ' . $hosting_varnish_varname . ': ' . $value);
provision_backend_invoke($hosting_name, "variable-set --exact " . $varname . ' ' . $value);
}
else {
drush_log('[hosting_varnish] NULL: ' . $hosting_varnish_varname);
}
}
}
}