Share repeated controller and service code
- AppController: joinUrl(), adminUrlFor(), setPollInterval() and protect() instead of copies in Admin-, Home-, Participate- and EmbedController. - PollMailer::sendSafely() replaces two try/catch blocks around mail sending. - Slide::optionIds() replaces five identical array_map() calls. - PollStateService: one pollPayload() for presenter and embed; the vote action passes the already loaded slide instead of loading it again. - ResultsService::forSlide() takes the answer/comment limit and the rating flag, so ReportService no longer queries answers, comments and the scale distribution twice and the export loads the slides only once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ad537b9b34
commit
3e44ded107
14 files changed
+189
-137
No files matched your search
@@ -183,7 +183,7 @@ class VoteService
|
||||
{
|
||||
$selected = $data['option_ids'] ?? $data['option_id'] ?? [];
|
||||
$selected = array_values(array_unique(array_map('intval', (array)$selected)));
|
||||
$validIds = array_map(fn($option) => $option->id, $slide->slide_options ?? []);
|
||||
$validIds = $slide->optionIds();
|
||||
$selected = array_values(array_intersect($selected, $validIds));
|
||||
|
||||
if ($selected === []) {
|
||||
@@ -205,7 +205,7 @@ class VoteService
|
||||
{
|
||||
$selected = $data['option_id'] ?? null;
|
||||
$id = is_scalar($selected) ? filter_var($selected, FILTER_VALIDATE_INT) : false;
|
||||
$validIds = array_map(fn($option) => $option->id, $slide->slide_options ?? []);
|
||||
$validIds = $slide->optionIds();
|
||||
if ($id === false || !in_array($id, $validIds, true)) {
|
||||
throw new VoteException(__('Bitte wähle eine Antwort aus.'));
|
||||
}
|
||||
@@ -229,7 +229,7 @@ class VoteService
|
||||
}
|
||||
$given[] = $id;
|
||||
}
|
||||
$validIds = array_map(fn($option) => $option->id, $slide->slide_options ?? []);
|
||||
$validIds = $slide->optionIds();
|
||||
$sortedGiven = $given;
|
||||
sort($sortedGiven);
|
||||
sort($validIds);
|
||||
|
||||
Reference in new issue
Block a user