|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* HiDev config for HiSite |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://github.com/hiqdev/hidev-hisite |
|
6
|
|
|
* @package hidev-hisite |
|
7
|
|
|
* @license BSD-3-Clause |
|
8
|
|
|
* @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace hidev\hisite\controllers; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Goal for HiSite. |
|
15
|
|
|
*/ |
|
16
|
|
|
class HiSiteController extends \hidev\controllers\DirectoryController |
|
17
|
|
|
{ |
|
18
|
|
|
protected $_env; |
|
19
|
|
|
protected $_debug; |
|
20
|
|
|
protected $_defines = []; |
|
21
|
|
|
protected $_nginx; |
|
22
|
|
|
protected $_vhost; |
|
23
|
|
|
|
|
24
|
|
|
public function setEnv($value) |
|
25
|
|
|
{ |
|
26
|
|
|
$this->_env = $value; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
1 |
|
public function getEnv() |
|
30
|
|
|
{ |
|
31
|
1 |
|
if ($this->_env === null) { |
|
32
|
1 |
|
$this->_env = 'dev'; |
|
33
|
1 |
|
} |
|
34
|
|
|
|
|
35
|
1 |
|
return $this->_env; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function setDebug($value) |
|
39
|
|
|
{ |
|
40
|
|
|
$this->_debug = $value; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
1 |
|
public function getDebug() |
|
44
|
|
|
{ |
|
45
|
1 |
|
if ($this->_debug === null) { |
|
46
|
1 |
|
$this->_debug = ($this->getEnv() === 'dev'); |
|
47
|
1 |
|
} |
|
48
|
|
|
|
|
49
|
1 |
|
return $this->_debug; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
1 |
|
public function setDefines(array $hash) |
|
53
|
|
|
{ |
|
54
|
1 |
|
$env = $this->getEnv(); |
|
55
|
|
|
$defaults = [ |
|
56
|
1 |
|
'YII_ENV' => "'$env'", |
|
57
|
1 |
|
'YII_DEBUG' => $this->getDebug() ? 'true' : 'false', |
|
58
|
1 |
|
]; |
|
59
|
1 |
|
$this->_defines = array_merge($this->_defines, $defaults, $hash); |
|
60
|
1 |
|
} |
|
61
|
|
|
|
|
62
|
1 |
|
public function getDefines() |
|
63
|
|
|
{ |
|
64
|
1 |
|
if (empty($this->_defines)) { |
|
65
|
1 |
|
$this->setDefines([]); |
|
66
|
1 |
|
} |
|
67
|
|
|
|
|
68
|
1 |
|
return $this->_defines; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function getNginx() |
|
72
|
|
|
{ |
|
73
|
|
|
if ($this->_nginx === null) { |
|
74
|
|
|
$this->_nginx = $this->takeGoal('nginx'); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
return $this->_nginx; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function getVhost() |
|
81
|
|
|
{ |
|
82
|
|
|
if ($this->_vhost === null) { |
|
83
|
|
|
$this->_vhost = $this->getNginx()->get('default'); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
return $this->_vhost; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
public function setVhost(array $params) |
|
90
|
|
|
{ |
|
91
|
|
|
foreach ($params as $key => $value) { |
|
92
|
|
|
$this->getVhost()->{$key} = $value; |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|