@@ -10,7 +10,6 @@ class ResponseFactory
10
10
{
11
11
protected $ rootView = 'app ' ;
12
12
protected $ sharedProps = [];
13
- protected $ sharedPropsCallbacks = [];
14
13
protected $ version = null ;
15
14
16
15
public function setRootView ($ name )
@@ -20,8 +19,8 @@ public function setRootView($name)
20
19
21
20
public function share ($ key , $ value = null )
22
21
{
23
- if ($ key instanceof Closure ) {
24
- $ this ->sharedPropsCallbacks [] = $ key ;
22
+ if (is_array ( $ key) ) {
23
+ $ this ->sharedProps = array_merge ( $ this -> sharedProps , $ key) ;
25
24
} else {
26
25
Arr::set ($ this ->sharedProps , $ key , $ value );
27
26
}
@@ -48,18 +47,11 @@ public function getVersion()
48
47
49
48
public function render ($ component , $ props = [])
50
49
{
51
- $ props = array_merge ($ this ->sharedProps , $ props );
52
-
53
- foreach ($ this ->sharedPropsCallbacks as $ callback ) {
54
- $ props = array_merge ($ props , App::call ($ callback ));
55
- }
56
-
57
- array_walk_recursive ($ props , function (&$ prop ) {
58
- if ($ prop instanceof Closure) {
59
- $ prop = App::call ($ prop );
60
- }
61
- });
62
-
63
- return new Response ($ component , $ props , $ this ->rootView , $ this ->getVersion ());
50
+ return new Response (
51
+ $ component ,
52
+ array_merge ($ this ->sharedProps , $ props ),
53
+ $ this ->rootView ,
54
+ $ this ->getVersion ()
55
+ );
64
56
}
65
57
}
0 commit comments