File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \UX \LiveComponent \Attribute \LiveProp ;
15
15
use Symfony \UX \TwigComponent \Attribute \PostMount ;
16
- use Symfony \UX \TwigComponent \Attribute \PreMount ;
17
16
18
17
/**
19
18
* @author Kevin Bond <[email protected] >
@@ -25,23 +24,19 @@ trait HasAttributesTrait
25
24
#[LiveProp(hydrateWith: 'hydrateAttributes ' , dehydrateWith: 'dehydrateAttributes ' )]
26
25
public ComponentAttributes $ attributes ;
27
26
28
- #[PreMount]
29
- public function preMountAttributes (array $ data ): array
27
+ public function setAttributes (array $ attributes ): void
30
28
{
31
- $ data ['_attributes ' ] = $ data ['attributes ' ] ?? [];
32
-
33
- unset($ data ['attributes ' ]);
34
-
35
- return $ data ;
29
+ $ this ->attributes = new ComponentAttributes ($ attributes );
36
30
}
37
31
38
32
#[PostMount(priority: -1000 )]
39
33
public function mountAttributes (array $ data ): array
40
34
{
41
- $ attributes = array_merge ($ data ['_attributes ' ], $ data );
42
- unset($ attributes ['_attributes ' ]);
35
+ if (isset ($ this ->attributes )) {
36
+ $ data = array_merge ($ this ->attributes ->all (), $ data );
37
+ }
43
38
44
- $ this ->attributes = new ComponentAttributes ($ attributes );
39
+ $ this ->attributes = new ComponentAttributes ($ data );
45
40
46
41
return [];
47
42
}
You can’t perform that action at this time.
0 commit comments