Skip to content

Commit

Permalink
Checking method existence before accessing it for participant days up…
Browse files Browse the repository at this point in the history
…date
  • Loading branch information
marekdedic committed Oct 8, 2023
1 parent ec73d65 commit 496d222
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Model\DTO\Participant\UpdateParticipant;

use function assert;
use function method_exists;

final class EditParticipantDialog extends Dialog
{
Expand Down Expand Up @@ -54,7 +55,7 @@ protected function createComponentForm(): BaseForm
$form->addInteger('days', 'Počet dní')
->setRequired('Musíte vyplnit počet dní')
->addRule(BaseForm::MIN, 'Minimální počet dní je %d', 0)
->setDefaultValue($participant->getDays());
->setDefaultValue(method_exists($participant, 'getDays') ? $participant->getDays() : 0);
}

$form->addText('payment', 'Částka')
Expand Down Expand Up @@ -84,7 +85,7 @@ protected function createComponentForm(): BaseForm
$changes[UpdateParticipant::FIELD_PAYMENT] = $values['payment'];
}

if ($this->isAllowedDaysUpdate && $values['days'] !== $participant->getDays()) {
if ($this->isAllowedDaysUpdate && method_exists($participant, 'getDays') && $values['days'] !== $participant->getDays()) {
$changes[UpdateParticipant::FIELD_DAYS] = $values['days'];
}

Expand Down

0 comments on commit 496d222

Please sign in to comment.