File tree Expand file tree Collapse file tree 2 files changed +22
-13
lines changed Expand file tree Collapse file tree 2 files changed +22
-13
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ class Manager
13
13
protected $ config ;
14
14
/**
15
15
* Replications
16
- * @var array
16
+ * @var Trigger[]
17
17
*/
18
18
protected $ replications ;
19
19
@@ -33,21 +33,23 @@ public function replication(?string $name = null)
33
33
$ name = $ name ?? $ this ->config ['default ' ] ?? 'default ' ;
34
34
35
35
if (!isset ($ this ->replications [$ name ])) {
36
- throw_if (
37
- !isset ($ this ->config ['replications ' ][$ name ]),
38
- new InvalidArgumentException ("Config 'trigger.replications. {$ name }' is undefined " , 1 )
39
- );
36
+ if (!isset ($ this ->config ['replications ' ][$ name ])) {
37
+ new InvalidArgumentException ("Config 'trigger.replications. {$ name }' is undefined " , 1 );
38
+ }
40
39
40
+ // load config
41
41
$ config = $ this ->config ['replications ' ][$ name ];
42
42
43
- $ this ->replications [$ name ] = tap (new Trigger ($ name , $ config ), function ($ trigger ) {
44
- /** @var Trigger $trigger */
45
- $ trigger ->loadRoutes ();
43
+ /** @var Trigger[] */
44
+ $ this ->replications [$ name ] = new Trigger ($ name , $ config );
45
+
46
+ // load routes
47
+ $ this ->replications [$ name ]->loadRoutes ();
46
48
47
- if ( $ trigger -> getConfig ( ' detect ' )) {
48
- $ trigger -> detectDatabasesAndTables ();
49
- }
50
- });
49
+ // auto detect
50
+ if ( $ this -> replications [ $ name ]-> getConfig ( ' detect ' )) {
51
+ $ this -> replications [ $ name ]-> detectDatabasesAndTables ();
52
+ }
51
53
}
52
54
53
55
return $ this ->replications [$ name ];
Original file line number Diff line number Diff line change 2
2
3
3
namespace Huangdijia \Trigger ;
4
4
5
- use Illuminate \Container \Container ;
6
5
use Exception ;
7
6
use Huangdijia \Trigger \EventSubscriber ;
7
+ use Illuminate \Container \Container ;
8
8
use Illuminate \Contracts \Queue \ShouldQueue ;
9
9
use Illuminate \Support \Arr ;
10
10
use Illuminate \Support \Carbon ;
18
18
19
19
class Trigger
20
20
{
21
+ /**
22
+ * @var string
23
+ */
21
24
protected $ name ;
25
+
26
+ /**
27
+ * @var array
28
+ */
22
29
protected $ config ;
23
30
24
31
/**
You can’t perform that action at this time.
0 commit comments