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
9090 'query ' => [],
9191 ];
9292
93- foreach ($ metadata ->getAllUrlMappings () as $ name => $ urlMapping ) {
93+ foreach ($ metadata ->getAllUrlMappings ($ mounted -> getComponent () ) as $ name => $ urlMapping ) {
9494 if (isset ($ values [$ name ]) && $ urlMapping ) {
9595 $ urlLiveProps [$ urlMapping ->mapPath ? 'path ' : 'query ' ][$ urlMapping ->as ?? $ name ] = $ values [$ name ];
9696 }
Original file line number Diff line number Diff line change @@ -69,10 +69,10 @@ public function getOnlyPropsThatAcceptUpdatesFromParent(array $inputProps): arra
6969 /**
7070 * @return UrlMapping[]
7171 */
72- public function getAllUrlMappings (): iterable
72+ public function getAllUrlMappings (object $ component ): iterable
7373 {
7474 $ urlMappings = [];
75- foreach ($ this ->livePropsMetadata as $ livePropMetadata ) {
75+ foreach ($ this ->getAllLivePropsMetadata ( $ component ) as $ livePropMetadata ) {
7676 if ($ livePropMetadata ->urlMapping ()) {
7777 $ urlMappings [$ livePropMetadata ->getName ()] = $ livePropMetadata ->urlMapping ();
7878 }
@@ -81,7 +81,7 @@ public function getAllUrlMappings(): iterable
8181 return $ urlMappings ;
8282 }
8383
84- public function hasQueryStringBindings ($ component ): bool
84+ public function hasQueryStringBindings (object $ component ): bool
8585 {
8686 foreach ($ this ->getAllLivePropsMetadata ($ component ) as $ livePropMetadata ) {
8787 if ($ livePropMetadata ->urlMapping ()) {
Original file line number Diff line number Diff line change @@ -54,6 +54,19 @@ class ComponentWithUrlBoundProps
5454 #[LiveProp]
5555 public ?bool $ maybeBoundPropInUrl = false ;
5656
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+
5770 public function getField2 (): string
5871 {
5972 return 'field2 ' ;
Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ public function getTestData(): iterable
112112 'propValue ' => 'search ' ,
113113 ],
114114 ];
115+
115116 $ address = new Address ();
116117 $ address ->address = '123 Main St ' ;
117118 $ address ->city = 'Anytown ' ;
@@ -126,6 +127,15 @@ public function getTestData(): iterable
126127 'propValue ' => '3 ' ,
127128 ],
128129 ];
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+ ];
129139 }
130140
131141 /**
You can’t perform that action at this time.
0 commit comments