forked from hechoendrupal/drupal-console
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserConfig.php
More file actions
50 lines (40 loc) · 1.05 KB
/
Copy pathUserConfig.php
File metadata and controls
50 lines (40 loc) · 1.05 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
44
45
46
47
48
49
50
<?php
/**
* @file
* Contains \Drupal\AppConsole\UserConfig.
*/
namespace Drupal\AppConsole;
class UserConfig extends Config
{
public function __construct($file = null)
{
parent::__construct($file);
$this->mergeConfig();
}
protected function mergeConfig()
{
$baseConfig = $this->getBaseConfig();
$userConfig = $this->getUserConfig();
$this->config = array_replace_recursive($baseConfig, $userConfig);
}
protected function getBaseConfig()
{
if (file_exists(__DIR__ . '/../config.yml')) {
return $this->readYamlFile(__DIR__ . '/../config.yml');
}
return [];
}
protected function getUserConfig()
{
if (file_exists($this->getUserHomeDir() . '/.console/config.yml')) {
return $this->readYamlFile(
$this->getUserHomeDir() . '/.console/config.yml'
);
}
return [];
}
public function getUserHomeDir()
{
return rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '/\\');
}
}