Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
services
t3o sites
voting.typo3.org
extensions
election
Commits
10fde8fa
Commit
10fde8fa
authored
Feb 13, 2021
by
Wolf Utz
Browse files
Fix import and export process of electors
parent
64584e23
Changes
3
Hide whitespace changes
Inline
Side-by-side
Classes/Controller/BeElectorController.php
View file @
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
);
}
...
...
Classes/Domain/Model/ElectorImport.php
View file @
10fde8fa
...
...
@@ -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'
])
)
;
}
}
Classes/Utility/CsvUtility.php
View file @
10fde8fa
...
...
@@ -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
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment