19
19
20
20
class DoctrineAnnotationListener extends AbstractListenerAggregate
21
21
{
22
- protected ObjectManager $ objectManager ;
23
-
24
- public function __construct (ObjectManager $ objectManager )
22
+ public function __construct (protected ObjectManager $ objectManager )
25
23
{
26
- $ this ->objectManager = $ objectManager ;
27
24
}
28
25
29
26
/**
@@ -33,45 +30,43 @@ public function attach(EventManagerInterface $events, $priority = 1)
33
30
{
34
31
$ this ->listeners [] = $ events ->attach (
35
32
EntityBasedFormBuilder::EVENT_CONFIGURE_FIELD ,
36
- [$ this , 'handleFilterField ' ]
33
+ [$ this , 'handleFilterField ' ],
37
34
);
38
35
$ this ->listeners [] = $ events ->attach (
39
36
EntityBasedFormBuilder::EVENT_CONFIGURE_FIELD ,
40
- [$ this , 'handleTypeField ' ]
37
+ [$ this , 'handleTypeField ' ],
41
38
);
42
39
$ this ->listeners [] = $ events ->attach (
43
40
EntityBasedFormBuilder::EVENT_CONFIGURE_FIELD ,
44
- [$ this , 'handleValidatorField ' ]
41
+ [$ this , 'handleValidatorField ' ],
45
42
);
46
43
$ this ->listeners [] = $ events ->attach (
47
44
EntityBasedFormBuilder::EVENT_CONFIGURE_FIELD ,
48
- [$ this , 'handleRequiredField ' ]
45
+ [$ this , 'handleRequiredField ' ],
49
46
);
50
47
$ this ->listeners [] = $ events ->attach (
51
48
EntityBasedFormBuilder::EVENT_EXCLUDE_FIELD ,
52
- [$ this , 'handleExcludeField ' ]
49
+ [$ this , 'handleExcludeField ' ],
53
50
);
54
51
$ this ->listeners [] = $ events ->attach (
55
52
EntityBasedFormBuilder::EVENT_CONFIGURE_ASSOCIATION ,
56
- [$ this , 'handleToOne ' ]
53
+ [$ this , 'handleToOne ' ],
57
54
);
58
55
$ this ->listeners [] = $ events ->attach (
59
56
EntityBasedFormBuilder::EVENT_CONFIGURE_ASSOCIATION ,
60
- [$ this , 'handleToMany ' ]
57
+ [$ this , 'handleToMany ' ],
61
58
);
62
59
$ this ->listeners [] = $ events ->attach (
63
60
EntityBasedFormBuilder::EVENT_CONFIGURE_ASSOCIATION ,
64
- [$ this , 'handleRequiredAssociation ' ]
61
+ [$ this , 'handleRequiredAssociation ' ],
65
62
);
66
63
$ this ->listeners [] = $ events ->attach (
67
64
EntityBasedFormBuilder::EVENT_EXCLUDE_ASSOCIATION ,
68
- [$ this , 'handleExcludeAssociation ' ]
65
+ [$ this , 'handleExcludeAssociation ' ],
69
66
);
70
67
}
71
68
72
- /**
73
- * @internal
74
- */
69
+ /** @internal */
75
70
public function handleToOne (EventInterface $ event ): void
76
71
{
77
72
$ metadata = $ event ->getParam ('metadata ' );
@@ -84,9 +79,7 @@ public function handleToOne(EventInterface $event): void
84
79
$ this ->mergeAssociationOptions ($ event ->getParam ('elementSpec ' ), $ mapping ['targetEntity ' ]);
85
80
}
86
81
87
- /**
88
- * @internal
89
- */
82
+ /** @internal */
90
83
public function handleToMany (EventInterface $ event ): void
91
84
{
92
85
$ metadata = $ event ->getParam ('metadata ' );
@@ -106,19 +99,15 @@ public function handleToMany(EventInterface $event): void
106
99
$ elementSpec ['spec ' ]['attributes ' ]['multiple ' ] = true ;
107
100
}
108
101
109
- /**
110
- * @internal
111
- */
102
+ /** @internal */
112
103
public function handleExcludeAssociation (EventInterface $ event ): bool
113
104
{
114
105
$ metadata = $ event ->getParam ('metadata ' );
115
106
116
107
return $ metadata && $ metadata ->isAssociationInverseSide ($ event ->getParam ('name ' ));
117
108
}
118
109
119
- /**
120
- * @internal
121
- */
110
+ /** @internal */
122
111
public function handleExcludeField (EventInterface $ event ): bool
123
112
{
124
113
$ metadata = $ event ->getParam ('metadata ' );
@@ -128,9 +117,7 @@ public function handleExcludeField(EventInterface $event): bool
128
117
$ metadata ->generatorType === ClassMetadata::GENERATOR_TYPE_IDENTITY ;
129
118
}
130
119
131
- /**
132
- * @internal
133
- */
120
+ /** @internal */
134
121
public function handleFilterField (EventInterface $ event ): void
135
122
{
136
123
$ metadata = $ event ->getParam ('metadata ' );
@@ -165,9 +152,7 @@ public function handleFilterField(EventInterface $event): void
165
152
}
166
153
}
167
154
168
- /**
169
- * @internal
170
- */
155
+ /** @internal */
171
156
public function handleRequiredAssociation (EventInterface $ event ): void
172
157
{
173
158
$ metadata = $ event ->getParam ('metadata ' );
@@ -206,9 +191,7 @@ public function handleRequiredAssociation(EventInterface $event): void
206
191
}
207
192
}
208
193
209
- /**
210
- * @internal
211
- */
194
+ /** @internal */
212
195
public function handleRequiredField (EventInterface $ event ): void
213
196
{
214
197
$ this ->prepareEvent ($ event );
@@ -223,9 +206,7 @@ public function handleRequiredField(EventInterface $event): void
223
206
$ inputSpec ['required ' ] = ! $ metadata ->isNullable ($ event ->getParam ('name ' ));
224
207
}
225
208
226
- /**
227
- * @internal
228
- */
209
+ /** @internal */
229
210
public function handleTypeField (EventInterface $ event ): void
230
211
{
231
212
$ metadata = $ event ->getParam ('metadata ' );
@@ -281,9 +262,7 @@ public function handleTypeField(EventInterface $event): void
281
262
$ elementSpec ['spec ' ]['type ' ] = $ type ;
282
263
}
283
264
284
- /**
285
- * @internal
286
- */
265
+ /** @internal */
287
266
public function handleValidatorField (EventInterface $ event ): void
288
267
{
289
268
$ mapping = $ this ->getFieldMapping ($ event );
@@ -333,10 +312,8 @@ public function handleValidatorField(EventInterface $event): void
333
312
}
334
313
}
335
314
336
- /**
337
- * @return mixed[]|null
338
- */
339
- protected function getFieldMapping (EventInterface $ event ): ?array
315
+ /** @return mixed[]|null */
316
+ protected function getFieldMapping (EventInterface $ event ): array |null
340
317
{
341
318
$ metadata = $ event ->getParam ('metadata ' );
342
319
if ($ metadata && $ metadata ->hasField ($ event ->getParam ('name ' ))) {
@@ -346,10 +323,8 @@ protected function getFieldMapping(EventInterface $event): ?array
346
323
return null ;
347
324
}
348
325
349
- /**
350
- * @return mixed[]|null
351
- */
352
- protected function getAssociationMapping (EventInterface $ event ): ?array
326
+ /** @return mixed[]|null */
327
+ protected function getAssociationMapping (EventInterface $ event ): array |null
353
328
{
354
329
$ metadata = $ event ->getParam ('metadata ' );
355
330
if ($ metadata && $ metadata ->hasAssociation ($ event ->getParam ('name ' ))) {
@@ -367,7 +342,7 @@ protected function mergeAssociationOptions(ArrayObject $elementSpec, string $tar
367
342
'object_manager ' => $ this ->objectManager ,
368
343
'target_class ' => $ targetEntity ,
369
344
],
370
- $ options
345
+ $ options,
371
346
);
372
347
373
348
$ elementSpec ['spec ' ]['options ' ] = $ options ;
0 commit comments