forked from ding2/ding2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.platformsh.php
91 lines (82 loc) · 3.35 KB
/
settings.platformsh.php
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
// Configure relationships.
if (isset($_ENV['PLATFORM_RELATIONSHIPS'])) {
$relationships = json_decode(base64_decode($_ENV['PLATFORM_RELATIONSHIPS']), TRUE);
if (empty($databases['default']) && !empty($relationships)) {
foreach ($relationships as $key => $relationship) {
$drupal_key = ($key === 'database') ? 'default' : $key;
foreach ($relationship as $instance) {
if (empty($instance['scheme']) || ($instance['scheme'] !== 'mysql' && $instance['scheme'] !== 'pgsql')) {
continue;
}
$database = [
'driver' => $instance['scheme'],
'database' => $instance['path'],
'username' => $instance['username'],
'password' => $instance['password'],
'host' => $instance['host'],
'port' => $instance['port'],
];
if (!empty($instance['query']['compression'])) {
$database['pdo'][PDO::MYSQL_ATTR_COMPRESS] = TRUE;
}
if (!empty($instance['query']['is_master'])) {
$databases[$drupal_key]['default'] = $database;
}
else {
$databases[$drupal_key]['slave'][] = $database;
}
}
}
}
}
// Configure private and temporary file paths.
if (isset($_ENV['PLATFORM_APP_DIR'])) {
if (!isset($conf['file_private_path'])) {
$conf['file_private_path'] = $_ENV['PLATFORM_APP_DIR'] . '/private';
}
if (!isset($conf['file_temporary_path'])) {
$conf['file_temporary_path'] = $_ENV['PLATFORM_APP_DIR'] . '/tmp';
}
}
// Import variables prefixed with 'drupal:' into $conf.
if (isset($_ENV['PLATFORM_VARIABLES'])) {
$variables = json_decode(base64_decode($_ENV['PLATFORM_VARIABLES']), TRUE);
$prefix_len = strlen('drupal:');
$drupal_globals = array('cookie_domain', 'installed_profile', 'drupal_hash_salt', 'base_url');
foreach ($variables as $name => $value) {
if (substr($name, 0, $prefix_len) == 'drupal:') {
$name = substr($name, $prefix_len);
if (in_array($name, $drupal_globals)) {
$GLOBALS[$name] = $value;
}
else {
$conf[$name] = $value;
}
}
}
}
// Set a default Drupal hash salt, based on a project-specific entropy value.
if (isset($_ENV['PLATFORM_PROJECT_ENTROPY']) && empty($drupal_hash_salt)) {
$drupal_hash_salt = $_ENV['PLATFORM_PROJECT_ENTROPY'];
}
// Setup Memcache
if (!empty($_ENV['PLATFORM_RELATIONSHIPS']) && extension_loaded('memcached')) {
$relationships = json_decode(base64_decode($_ENV['PLATFORM_RELATIONSHIPS']), true);
// If you named your memcached relationship something other than "cache", set that here.
$relationship_name = 'cache';
if (!empty($relationships[$relationship_name])) {
// These lines tell Drupal to use memcached as a backend.
// Comment out just these lines if you need to disable it for some reason and
// fall back to the default database cache.
$conf['cache_backends'][] = 'profiles/ding2/modules/contrib/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
// While we're at it, use Memcache for locking, too.
$conf['lock_inc'] = 'profiles/ding2/modules/contrib/memcache/memcache-lock.inc';
foreach ($relationships[$relationship_name] as $endpoint) {
$host = sprintf("%s:%d", $endpoint['host'], $endpoint['port']);
$conf['memcache_servers'][$host] = 'default';
}
}
}