Share repeated controller and service code
CI / Deploy / test (push) Successful in 53s
CI / Deploy / deploy (push) Skipped

- 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:
gnilebeinandClaude Opus 5.5 committed 2026-11-08 22:50:56 +01:00
1 parent ad537b9b34
commit 3e44ded107
14 files changed
+189 -137

No files matched your search

+3 -4
View File
@@ -8,7 +8,6 @@ use App\Model\Table\PollsTable;
use App\Service\PollStateService;
use App\Service\VoteException;
use App\Service\VoteService;
use Cake\Core\Configure;
use Cake\Event\EventInterface;
use Cake\Http\Cookie\Cookie;
use Cake\Http\Exception\NotFoundException;
@@ -86,10 +85,10 @@ class ParticipateController extends AppController
$stateService = new PollStateService();
$slide = $poll->is_active ? $stateService->currentSlide($poll) : null;
$participantHash = $this->participantHash($poll);
$state = $stateService->forParticipant($poll, $participantHash);
$state = $stateService->forParticipant($poll, $participantHash, $slide);
$this->set(compact('poll', 'slide', 'state', 'participantHash'));
$this->set('pollIntervalMs', (int)Configure::read('Plenario.pollIntervalMs', 2000));
$this->setPollInterval();
}
/**
@@ -146,7 +145,7 @@ class ParticipateController extends AppController
return $this->json([
'ok' => $ok,
'message' => $message,
'state' => $stateService->forParticipant($poll, $this->participantHash($poll)),
'state' => $stateService->forParticipant($poll, $this->participantHash($poll), $slide),
], $status);
}
$ok ? $this->Flash->success($message) : $this->Flash->error($message);