7
7
* @package supervisor-config
8
8
* @author The Weezqyd
9
9
**/
10
+ use Exception ;
11
+
10
12
class SupervisorConfiguration
11
13
{
12
14
/**
@@ -32,12 +34,6 @@ class SupervisorConfiguration
32
34
stdout_logfile = {PATH}/storage/logs/worker.log ' ;
33
35
34
36
35
-
36
- public function __construct (Tenant $ tenant )
37
- {
38
- $ this ->tenant = $ tenant ;
39
- }
40
-
41
37
/**
42
38
* Set the config values
43
39
*
@@ -63,10 +59,36 @@ private function set()
63
59
public function create ()
64
60
{
65
61
$ configs = $ this ->set ();
66
- $ this ->save ($ configs );
67
- return $ configs ;
62
+ return $ this ->save ($ configs );
63
+
64
+ }
65
+ /**
66
+ * Set tenant object
67
+ *
68
+ * @return void
69
+ * @param object $tenant
70
+ **/
71
+ private function setTenant (Tenant $ tenant )
72
+ {
73
+ $ this ->tenant = $ tenant ;
68
74
}
69
75
76
+ /**
77
+ * Get tenant from storage
78
+ *
79
+ * @return void
80
+ * @param mixed $tenant
81
+ **/
82
+ public function getTenant ($ tenant )
83
+ {
84
+ $ model = new Tenant ();
85
+
86
+ $ instance = $ model ->whereId ($ tenant )->orWhere ('uuid ' ,$ tenant )->orWhere ('domain ' , $ tenant )->first ();
87
+ if (is_null ($ instance ))
88
+ throw new Exceptions \TenantNotResolvedException ("Tenant not resolved or does not exist " );
89
+
90
+ $ this ->setTenant ($ instance );
91
+ }
70
92
/**
71
93
* undocumented function
72
94
*
@@ -75,6 +97,8 @@ public function create()
75
97
**/
76
98
protected function save ($ conf )
77
99
{
78
- return file_put_contents (base_path ('supervisor/elimuswift- ' .$ this ->tenant ->uuid .'.conf ' ), $ conf );
100
+ $ file = base_path ('supervisor/elimuswift- ' .$ this ->tenant ->uuid .'.conf ' );
101
+ file_put_contents ($ file , $ conf );
102
+ return $ file ;
79
103
}
80
104
} // END class SupervisorConfiguration
0 commit comments