Commit ab6c6c9a authored by Felix Herrmann's avatar Felix Herrmann
Browse files

Merge branch 'fix/import-export' into 'task/be-functionality'

Fix import and export process of electors

See merge request services/voting.typo3.org/extensions/election!30
parents 64584e23 10fde8fa
......@@ -27,6 +27,8 @@ use T3o\Election\Domain\Service\ElectionInvitationService;
use T3o\Election\Utility\CsvUtility;
use T3o\Election\Utility\FileUtility;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
class BeElectorController extends AbstractProtectedBeController
......@@ -119,7 +121,9 @@ class BeElectorController extends AbstractProtectedBeController
*/
public function importAction(?Electorate $election = null): void
{
$this->view->assign('electorImport', new ElectorImportDto($election, $this->electorateRepository->findAll()));
$electorates = $this->electorateRepository->findAll();
$electorates = $electorates instanceof QueryResultInterface ? $electorates->toArray() : [];
$this->view->assign('electorImport', new ElectorImportDto($election, $electorates));
}
public function listAction(): void
......@@ -169,8 +173,10 @@ class BeElectorController extends AbstractProtectedBeController
$elector->setLastName($electorImport->getLastName());
$elector->setGender($electorImport->getGender());
$elector->setEmail($electorImport->getEmail());
$elector->setElectionInvitations(0);
$elector->addElectorate($electorImport->getElectorate());
$elector->setElectionInvitations(new ObjectStorage());
if (!is_null($electorImport->getElectorate())) {
$elector->addElectorate($electorImport->getElectorate());
}
$this->electorRepository->add($elector);
$this->electorImportRepository->remove($electorImport);
}
......
......@@ -36,6 +36,6 @@ class ElectorImport extends AbstractPerson
$this->setMiddleName($importInformation['middleName']);
$this->setLastName($importInformation['lastName']);
$this->setEmail($importInformation['email']);
$this->setGender($importInformation['gender']);
$this->setGender(intval($importInformation['gender']));
}
}
......@@ -52,7 +52,7 @@ class CsvUtility
foreach ($objects as $object) {
$cells = [];
foreach ($propertyNames as $propertyName) {
$cells[] = $this->escapeValue(ObjectAccess::getPropertyPath($object, $propertyName));
$cells[] = $this->escapeValue((string) ObjectAccess::getPropertyPath($object, $propertyName));
}
$result .= implode(';', $cells) . chr(10);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment