forked from HEXA-UA/supervisor-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule.php
More file actions
60 lines (49 loc) · 1.37 KB
/
Copy pathModule.php
File metadata and controls
60 lines (49 loc) · 1.37 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
51
52
53
54
55
56
57
58
59
60
<?php
namespace supervisormanager;
use supervisormanager\components\supervisor\ConnectionInterface;
use supervisormanager\components\supervisor\Supervisor;
use yii\base\Event;
use Zend\XmlRpc\Client;
/**
* @property array supervisorConnection
*/
class Module extends \yii\base\Module
{
/**
* @var array Supervisor client authenticate data.
*/
public $authData = [];
/**
* @var string
*/
public $controllerNamespace = 'supervisormanager\controllers';
public function init()
{
parent::init();
Event::on(Supervisor::className(), Supervisor::EVENT_CONFIG_CHANGED,
function () {
exec('supervisorctl update', $output, $status);
}
);
\Yii::configure($this, require(__DIR__ . '/config.php'));
$this->params['supervisorConnection'] = array_merge(
$this->params['supervisorConnection'], $this->authData
);
$this->registerIoC();
}
protected function registerIoC()
{
\Yii::$container->set(
Client::class,
function () {
return new Client(
$this->params['supervisorConnection']['url']
);
}
);
\Yii::$container->set(
ConnectionInterface::class,
$this->params['supervisorConnection']
);
}
}