File tree Expand file tree Collapse file tree 4 files changed +27
-4
lines changed Expand file tree Collapse file tree 4 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ private function getLiveProps(MountedComponent $mounted): array
90
90
'query ' => [],
91
91
];
92
92
93
- foreach ($ metadata ->getAllUrlMappings () as $ name => $ urlMapping ) {
93
+ foreach ($ metadata ->getAllUrlMappings ($ mounted -> getComponent () ) as $ name => $ urlMapping ) {
94
94
if (isset ($ values [$ name ]) && $ urlMapping ) {
95
95
$ urlLiveProps [$ urlMapping ->mapPath ? 'path ' : 'query ' ][$ urlMapping ->as ?? $ name ] = $ values [$ name ];
96
96
}
Original file line number Diff line number Diff line change @@ -69,10 +69,10 @@ public function getOnlyPropsThatAcceptUpdatesFromParent(array $inputProps): arra
69
69
/**
70
70
* @return UrlMapping[]
71
71
*/
72
- public function getAllUrlMappings (): iterable
72
+ public function getAllUrlMappings (object $ component ): iterable
73
73
{
74
74
$ urlMappings = [];
75
- foreach ($ this ->livePropsMetadata as $ livePropMetadata ) {
75
+ foreach ($ this ->getAllLivePropsMetadata ( $ component ) as $ livePropMetadata ) {
76
76
if ($ livePropMetadata ->urlMapping ()) {
77
77
$ urlMappings [$ livePropMetadata ->getName ()] = $ livePropMetadata ->urlMapping ();
78
78
}
@@ -81,7 +81,7 @@ public function getAllUrlMappings(): iterable
81
81
return $ urlMappings ;
82
82
}
83
83
84
- public function hasQueryStringBindings ($ component ): bool
84
+ public function hasQueryStringBindings (object $ component ): bool
85
85
{
86
86
foreach ($ this ->getAllLivePropsMetadata ($ component ) as $ livePropMetadata ) {
87
87
if ($ livePropMetadata ->urlMapping ()) {
Original file line number Diff line number Diff line change @@ -54,6 +54,19 @@ class ComponentWithUrlBoundProps
54
54
#[LiveProp]
55
55
public ?bool $ maybeBoundPropInUrl = false ;
56
56
57
+ #[LiveProp(url: new UrlMapping (as: 'p ' ), modifier: 'modifyPropertyWithModifierAndAlias ' )]
58
+ public ?string $ propertyWithModifierAndAlias = null ;
59
+
60
+ public function modifyPropertyWithModifierAndAlias (LiveProp $ liveProp ): LiveProp
61
+ {
62
+ $ urlMapping = $ liveProp ->url ();
63
+ if (!$ urlMapping instanceof UrlMapping) {
64
+ return $ liveProp ;
65
+ }
66
+
67
+ return $ liveProp ->withUrl (new UrlMapping (as: 'alias_ ' . $ urlMapping ->as ));
68
+ }
69
+
57
70
public function getField2 (): string
58
71
{
59
72
return 'field2 ' ;
Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ public function getTestData(): iterable
112
112
'propValue ' => 'search ' ,
113
113
],
114
114
];
115
+
115
116
$ address = new Address ();
116
117
$ address ->address = '123 Main St ' ;
117
118
$ address ->city = 'Anytown ' ;
@@ -126,6 +127,15 @@ public function getTestData(): iterable
126
127
'propValue ' => '3 ' ,
127
128
],
128
129
];
130
+
131
+ yield 'query with alias ("p") and modifier (prefix by "alias_") ' => [
132
+ 'previousLocation ' => '/ ' ,
133
+ 'expectedLocation ' => '/?alias_p=test ' ,
134
+ 'props ' => [
135
+ 'propertyWithModifierAndAlias ' => 'test ' ,
136
+ ],
137
+ 'args ' => [],
138
+ ];
129
139
}
130
140
131
141
/**
You can’t perform that action at this time.
0 commit comments