File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 12
12
namespace Symfony \UX \TwigComponent ;
13
13
14
14
use Symfony \UX \LiveComponent \Attribute \LiveProp ;
15
+ use Symfony \UX \TwigComponent \Attribute \PostMount ;
15
16
use Symfony \UX \TwigComponent \Attribute \PreMount ;
16
17
17
18
/**
@@ -25,13 +26,26 @@ trait HasAttributesTrait
25
26
public ComponentAttributes $ attributes ;
26
27
27
28
#[PreMount]
28
- public function mapAttributes (array $ data ): array
29
+ public function preMountAttributes (array $ data ): array
29
30
{
30
- $ data ['attributes ' ] = new ComponentAttributes ($ data ['attributes ' ] ?? []);
31
+ $ data ['_attributes ' ] = $ data ['attributes ' ] ?? [];
32
+
33
+ unset($ data ['attributes ' ]);
31
34
32
35
return $ data ;
33
36
}
34
37
38
+ #[PostMount]
39
+ public function mountAttributes (array $ data ): array
40
+ {
41
+ $ attributes = array_merge ($ data ['_attributes ' ], $ data );
42
+ unset($ attributes ['_attributes ' ]);
43
+
44
+ $ this ->attributes = new ComponentAttributes ($ attributes );
45
+
46
+ return [];
47
+ }
48
+
35
49
public static function dehydrateAttributes (ComponentAttributes $ attributes ): array
36
50
{
37
51
return $ attributes ->all ();
You can’t perform that action at this time.
0 commit comments