@@ -1127,7 +1127,9 @@ public function importAccountsJson(array $data, ?string &$message = null, ?array
11271127 */
11281128 protected function importTeamData (array $ teamData , ?string &$ message , ?array &$ saved = null ): int
11291129 {
1130+ /** @var TeamAffiliation[] $createdAffiliations */
11301131 $ createdAffiliations = [];
1132+ /** @var TeamCategory[] $createdCategories */
11311133 $ createdCategories = [];
11321134 $ createdTeams = [];
11331135 $ updatedTeams = [];
@@ -1140,6 +1142,14 @@ protected function importTeamData(array $teamData, ?string &$message, ?array &$s
11401142 if (!empty ($ teamItem ['team_affiliation ' ]['shortname ' ])) {
11411143 // First look up if the affiliation already exists.
11421144 $ 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+ }
11431153 if (!$ teamAffiliation ) {
11441154 $ teamAffiliation = new TeamAffiliation ();
11451155 $ propertyAccessor = PropertyAccess::createPropertyAccessor ();
@@ -1166,6 +1176,15 @@ protected function importTeamData(array $teamData, ?string &$message, ?array &$s
11661176 }
11671177 } elseif (!empty ($ teamItem ['team_affiliation ' ]['externalid ' ])) {
11681178 $ 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+
11691188 if (!$ teamAffiliation ) {
11701189 $ teamAffiliation = new TeamAffiliation ();
11711190 $ teamAffiliation
@@ -1196,6 +1215,14 @@ protected function importTeamData(array $teamData, ?string &$message, ?array &$s
11961215
11971216 if (!empty ($ teamItem ['team ' ]['categoryid ' ])) {
11981217 $ 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+ }
11991226 if (!$ teamCategory ) {
12001227 $ teamCategory = new TeamCategory ();
12011228 $ teamCategory
0 commit comments