@@ -23,19 +23,17 @@ class Response implements Responsable
23
23
24
24
protected $ component ;
25
25
protected $ props ;
26
- protected $ persisted ;
27
26
protected $ rootView ;
28
27
protected $ version ;
29
28
protected $ viewData = [];
30
29
31
30
/**
32
31
* @param array|Arrayable $props
33
32
*/
34
- public function __construct (string $ component , array $ props , string $ rootView = 'app ' , string $ version = '' , array $ persisted = [] )
33
+ public function __construct (string $ component , array $ props , string $ rootView = 'app ' , string $ version = '' )
35
34
{
36
35
$ this ->component = $ component ;
37
36
$ this ->props = $ props instanceof Arrayable ? $ props ->toArray () : $ props ;
38
- $ this ->persisted = $ persisted ;
39
37
$ this ->rootView = $ rootView ;
40
38
$ this ->version = $ version ;
41
39
}
@@ -129,6 +127,8 @@ public function resolveProperties(Request $request, array $props): array
129
127
$ props = $ this ->resolveExcept ($ request , $ props );
130
128
}
131
129
130
+ $ props = $ this ->resolveAlways ($ props );
131
+
132
132
$ props = $ this ->resolvePropertyInstances ($ props , $ request );
133
133
134
134
return $ props ;
@@ -164,10 +164,7 @@ public function resolveArrayableProperties(array $props, Request $request, bool
164
164
*/
165
165
public function resolveOnly (Request $ request , array $ props ): array
166
166
{
167
- $ only = array_merge (
168
- array_filter (explode (', ' , $ request ->header (Header::PARTIAL_ONLY , '' ))),
169
- $ this ->persisted
170
- );
167
+ $ only = array_filter (explode (', ' , $ request ->header (Header::PARTIAL_ONLY , '' )));
171
168
172
169
$ value = [];
173
170
@@ -190,6 +187,21 @@ public function resolveExcept(Request $request, array $props): array
190
187
return $ props ;
191
188
}
192
189
190
+ /**
191
+ * Resolve `always` properties that should always be included on all visits, regardless of "only" or "except" requests.
192
+ */
193
+ public function resolveAlways (array $ props ): array
194
+ {
195
+ $ always = array_filter ($ this ->props , static function ($ prop ) {
196
+ return $ prop instanceof AlwaysProp;
197
+ });
198
+
199
+ return array_merge (
200
+ $ always ,
201
+ $ props
202
+ );
203
+ }
204
+
193
205
/**
194
206
* Resolve all necessary class instances in the given props.
195
207
*/
@@ -204,6 +216,10 @@ public function resolvePropertyInstances(array $props, Request $request): array
204
216
$ value = App::call ($ value );
205
217
}
206
218
219
+ if ($ value instanceof AlwaysProp) {
220
+ $ value = App::call ($ value );
221
+ }
222
+
207
223
if ($ value instanceof PromiseInterface) {
208
224
$ value = $ value ->wait ();
209
225
}
0 commit comments