6
6
use App \Entity \Team ;
7
7
use App \Service \ConfigurationService ;
8
8
use App \Service \DOMJudgeService ;
9
+ use App \Service \EventLogService ;
9
10
use Doctrine \ORM \EntityManagerInterface ;
10
11
use Symfony \Component \Form \AbstractType ;
11
12
use Symfony \Component \Form \Extension \Core \Type \ChoiceType ;
@@ -22,6 +23,7 @@ public function __construct(
22
23
private readonly EntityManagerInterface $ em ,
23
24
private readonly ConfigurationService $ config ,
24
25
private readonly DOMJudgeService $ dj ,
26
+ private readonly EventLogService $ eventLogService ,
25
27
) {}
26
28
27
29
public function buildForm (FormBuilderInterface $ builder , array $ options ): void
@@ -33,12 +35,12 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
33
35
34
36
$ limitToTeam = $ options ['limit_to_team ' ] ?? null ;
35
37
if ($ limitToTeam ) {
36
- $ recipientOptions [sprintf ( " %s (t%s) " , $ limitToTeam -> getEffectiveName (), $ limitToTeam-> getTeamid () )] = $ limitToTeam ->getTeamid ();
38
+ $ recipientOptions [$ this -> getTeamLabel ( $ limitToTeam )] = $ limitToTeam ->getTeamid ();
37
39
} else {
38
40
/** @var Team|null $limitToTeam */
39
41
$ teams = $ this ->em ->getRepository (Team::class)->findAll ();
40
42
foreach ($ teams as $ team ) {
41
- $ recipientOptions [sprintf ( " %s (t%s) " , $ team -> getEffectiveName (), $ team-> getTeamid () )] = $ team ->getTeamid ();
43
+ $ recipientOptions [$ this -> getTeamLabel ( $ team )] = $ team ->getTeamid ();
42
44
}
43
45
}
44
46
@@ -110,4 +112,17 @@ public function configureOptions(OptionsResolver $resolver): void
110
112
{
111
113
$ resolver ->setDefault ('limit_to_team ' , null );
112
114
}
115
+
116
+ private function getTeamLabel (Team $ team ): string
117
+ {
118
+ if ($ team ->getLabel ()) {
119
+ return sprintf ('%s (%s) ' , $ team ->getEffectiveName (), $ team ->getLabel ());
120
+ }
121
+
122
+ if ($ this ->eventLogService ->externalIdFieldForEntity ($ team )) {
123
+ return sprintf ('%s (%s) ' , $ team ->getEffectiveName (), $ team ->getExternalId ());
124
+ }
125
+
126
+ return sprintf ('%s (t%s) ' , $ team ->getEffectiveName (), $ team ->getTeamid ());
127
+ }
113
128
}
0 commit comments