@@ -1127,7 +1127,9 @@ public function importAccountsJson(array $data, ?string &$message = null, ?array
1127
1127
*/
1128
1128
protected function importTeamData (array $ teamData , ?string &$ message , ?array &$ saved = null ): int
1129
1129
{
1130
+ /** @var TeamAffiliation[] $createdAffiliations */
1130
1131
$ createdAffiliations = [];
1132
+ /** @var TeamCategory[] $createdCategories */
1131
1133
$ createdCategories = [];
1132
1134
$ createdTeams = [];
1133
1135
$ updatedTeams = [];
@@ -1140,6 +1142,14 @@ protected function importTeamData(array $teamData, ?string &$message, ?array &$s
1140
1142
if (!empty ($ teamItem ['team_affiliation ' ]['shortname ' ])) {
1141
1143
// First look up if the affiliation already exists.
1142
1144
$ teamAffiliation = $ this ->em ->getRepository (TeamAffiliation::class)->findOneBy (['shortname ' => $ teamItem ['team_affiliation ' ]['shortname ' ]]);
1145
+ if (!$ teamAffiliation ) {
1146
+ foreach ($ createdAffiliations as $ createdAffiliation ) {
1147
+ if ($ createdAffiliation ->getShortname () === $ teamItem ['team_affiliation ' ]['shortname ' ]) {
1148
+ $ teamAffiliation = $ createdAffiliation ;
1149
+ break ;
1150
+ }
1151
+ }
1152
+ }
1143
1153
if (!$ teamAffiliation ) {
1144
1154
$ teamAffiliation = new TeamAffiliation ();
1145
1155
$ propertyAccessor = PropertyAccess::createPropertyAccessor ();
@@ -1166,6 +1176,15 @@ protected function importTeamData(array $teamData, ?string &$message, ?array &$s
1166
1176
}
1167
1177
} elseif (!empty ($ teamItem ['team_affiliation ' ]['externalid ' ])) {
1168
1178
$ teamAffiliation = $ this ->em ->getRepository (TeamAffiliation::class)->findOneBy (['externalid ' => $ teamItem ['team_affiliation ' ]['externalid ' ]]);
1179
+ if (!$ teamAffiliation ) {
1180
+ foreach ($ createdAffiliations as $ createdAffiliation ) {
1181
+ if ($ createdAffiliation ->getExternalid () === $ teamItem ['team_affiliation ' ]['externalid ' ]) {
1182
+ $ teamAffiliation = $ createdAffiliation ;
1183
+ break ;
1184
+ }
1185
+ }
1186
+ }
1187
+
1169
1188
if (!$ teamAffiliation ) {
1170
1189
$ teamAffiliation = new TeamAffiliation ();
1171
1190
$ teamAffiliation
@@ -1196,6 +1215,14 @@ protected function importTeamData(array $teamData, ?string &$message, ?array &$s
1196
1215
1197
1216
if (!empty ($ teamItem ['team ' ]['categoryid ' ])) {
1198
1217
$ teamCategory = $ this ->em ->getRepository (TeamCategory::class)->findOneBy (['externalid ' => $ teamItem ['team ' ]['categoryid ' ]]);
1218
+ if (!$ teamCategory ) {
1219
+ foreach ($ createdCategories as $ createdCategory ) {
1220
+ if ($ createdCategory ->getExternalid () === $ teamItem ['team ' ]['categoryid ' ]) {
1221
+ $ teamCategory = $ createdCategory ;
1222
+ break ;
1223
+ }
1224
+ }
1225
+ }
1199
1226
if (!$ teamCategory ) {
1200
1227
$ teamCategory = new TeamCategory ();
1201
1228
$ teamCategory
0 commit comments