@@ -19,6 +19,11 @@ class Sandbox
19
19
*/
20
20
protected $ snapshot ;
21
21
22
+ /**
23
+ * @var \Illuminate\Config\Repository
24
+ */
25
+ protected $ config ;
26
+
22
27
/**
23
28
* @var boolean
24
29
*/
@@ -41,6 +46,7 @@ public static function make(Application $application)
41
46
public function __construct (Application $ application )
42
47
{
43
48
$ this ->setApplication ($ application );
49
+ $ this ->setInitialConfig ($ application );
44
50
}
45
51
46
52
/**
@@ -53,6 +59,16 @@ public function setApplication(Application $application)
53
59
$ this ->application = $ application ;
54
60
}
55
61
62
+ /**
63
+ * Set config snapshot.
64
+ *
65
+ * @param \SwooleTW\Http\Server\Application
66
+ */
67
+ protected function setInitialConfig (Application $ application )
68
+ {
69
+ $ this ->config = clone $ application ->getApplication ()['config ' ];
70
+ }
71
+
56
72
/**
57
73
* Get an application snapshot
58
74
*
@@ -75,20 +91,19 @@ public function getApplication()
75
91
*/
76
92
protected function resetLaravelApp ($ application )
77
93
{
78
- if ($ this ->isFramework ('laravel ' )) {
79
- $ application ->bootstrapWith ([
80
- 'Illuminate\Foundation\Bootstrap\LoadConfiguration '
81
- ]);
82
- } elseif ($ this ->isFramework ('lumen ' )) {
83
- $ reflector = new \ReflectionMethod (LumenApplication::class, 'registerConfigBindings ' );
84
- $ reflector ->setAccessible (true );
85
- $ reflector ->invoke ($ application );
86
- }
87
-
94
+ $ this ->resetConfigInstance ($ application );
88
95
$ this ->rebindRouterContainer ($ application );
89
96
$ this ->rebindViewContainer ($ application );
90
97
}
91
98
99
+ /**
100
+ * Reset laravel/lumen's config to initial values.
101
+ */
102
+ protected function resetConfigInstance ($ application )
103
+ {
104
+ $ application ->instance ('config ' , clone $ this ->config );
105
+ }
106
+
92
107
/**
93
108
* Rebind laravel's container in router.
94
109
*/
0 commit comments