File tree Expand file tree Collapse file tree 4 files changed +69
-1
lines changed Expand file tree Collapse file tree 4 files changed +69
-1
lines changed Original file line number Diff line number Diff line change 3
3
## 2.14.0
4
4
5
5
- Add support for URL binding in ` LiveProp `
6
+ - Allow multiple ` LiveListener ` attributes on a single method.
6
7
7
8
## 2.13.2
8
9
Original file line number Diff line number Diff line change 21
21
*
22
22
* @experimental
23
23
*/
24
- #[\Attribute(\Attribute::TARGET_METHOD )]
24
+ #[\Attribute(\Attribute::TARGET_METHOD | \Attribute:: IS_REPEATABLE )]
25
25
class LiveListener extends LiveAction
26
26
{
27
27
/**
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <[email protected] >
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \UX \LiveComponent \Tests \Fixtures \Component ;
13
+
14
+ use Symfony \UX \LiveComponent \Attribute \AsLiveComponent ;
15
+ use Symfony \UX \LiveComponent \Attribute \LiveListener ;
16
+ use Symfony \UX \LiveComponent \DefaultActionTrait ;
17
+
18
+ #[AsLiveComponent]
19
+ class ComponentWithRepeatedLiveListener
20
+ {
21
+ use DefaultActionTrait;
22
+
23
+ #[LiveListener('bar ' )]
24
+ public function onBar (): void
25
+ {
26
+ }
27
+
28
+ #[LiveListener('foo ' )]
29
+ #[LiveListener('bar ' )]
30
+ #[LiveListener('foo:bar ' )]
31
+ public function onFooBar (): void
32
+ {
33
+ }
34
+ }
Original file line number Diff line number Diff line change 19
19
use Symfony \UX \LiveComponent \Attribute \PreDehydrate ;
20
20
use Symfony \UX \LiveComponent \Attribute \PreReRender ;
21
21
use Symfony \UX \LiveComponent \Tests \Fixtures \Component \Component5 ;
22
+ use Symfony \UX \LiveComponent \Tests \Fixtures \Component \ComponentWithRepeatedLiveListener ;
22
23
23
24
/**
24
25
* @author Kevin Bond <[email protected] >
@@ -137,6 +138,38 @@ public function testCanGetLiveListenersFromClassString(): void
137
138
], $ liveListeners [0 ]);
138
139
}
139
140
141
+ public function testCanGetRepeatedLiveListeners (): void
142
+ {
143
+ $ liveListeners = AsLiveComponent::liveListeners (new ComponentWithRepeatedLiveListener ());
144
+
145
+ $ this ->assertCount (4 , $ liveListeners );
146
+ $ this ->assertSame ([
147
+ [
148
+ 'action ' => 'onBar ' ,
149
+ 'event ' => 'bar ' ,
150
+ ],
151
+ [
152
+ 'action ' => 'onFooBar ' ,
153
+ 'event ' => 'foo ' ,
154
+ ],
155
+ [
156
+ 'action ' => 'onFooBar ' ,
157
+ 'event ' => 'bar ' ,
158
+ ],
159
+ [
160
+ 'action ' => 'onFooBar ' ,
161
+ 'event ' => 'foo:bar ' ,
162
+ ],
163
+ ], $ liveListeners );
164
+ }
165
+
166
+ public function testCanGetRepeatedLiveListenersFromClassString (): void
167
+ {
168
+ $ liveListeners = AsLiveComponent::liveListeners (ComponentWithRepeatedLiveListener::class);
169
+
170
+ $ this ->assertCount (4 , $ liveListeners );
171
+ }
172
+
140
173
public function testCanCheckIfMethodIsAllowed (): void
141
174
{
142
175
$ component = new Component5 ();
You can’t perform that action at this time.
0 commit comments