Skip to content

Commit

Permalink
Update webapp/src/Service/ImportExportService.php
Browse files Browse the repository at this point in the history
Co-authored-by: Nicky Gerritsen <[email protected]>
  • Loading branch information
vmcj and nickygerritsen authored Nov 7, 2023
1 parent 010a9c5 commit 9335b5d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions webapp/src/Service/ImportExportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,10 @@ public function importContestData(mixed $data, ?string &$errorMessage = null, st
if ($shadow) {
$externalSource = $this->em->getRepository(ExternalContestSource::class)->findOneBy(['contest' => $contest]) ?: new ExternalContestSource();
$externalSource->setContest($contest);
foreach (['source', 'username', 'password', 'type'] as $field) {
// Overwrite the existing value if the property is defined in the data: $externalSource-setSource($data['shadow']['source'])
foreach ($shadow as $field => $value) {
$fieldFunc = 'set'.ucwords($field);
$fieldArgs = [$shadow[$field]];
if (isset($shadow[$field])) {
$fieldArgs = [$value];
if (method_exists($externalSource, $fieldFunc)) {
$externalSource->$fieldFunc(...$fieldArgs);
}
}
Expand Down

0 comments on commit 9335b5d

Please sign in to comment.