Skip to content

Commit

Permalink
fixed role switch from PatrolParticipant & TroopParticipant
Browse files Browse the repository at this point in the history
  • Loading branch information
Lung committed Jan 14, 2024
1 parent 6a276aa commit 45bbc58
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ parameters:
# 3rd party library
message: '#Access to an undefined property Skautis\\Skautis::\$OrganizationUnit\.#'
path: src\Skautis\SkautisService.php
-
# database manipulation
message: '#kissj\\Participant\\Patrol\\PatrolParticipant::\$patrolLeader \(kissj\\Participant\\Patrol\\PatrolLeader\) does not accept null\.#'
path: src\Participant\ParticipantService.php
exceptions:
uncheckedExceptionRegexes:
- '#Exception#'
9 changes: 9 additions & 0 deletions src/Participant/ParticipantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use kissj\Mailer\PhpMailerWrapper;
use kissj\Participant\Guest\Guest;
use kissj\Participant\Patrol\PatrolLeader;
use kissj\Participant\Patrol\PatrolParticipant;
use kissj\Participant\Troop\TroopLeader;
use kissj\Participant\Troop\TroopParticipant;
use kissj\Participant\Troop\TroopParticipantRepository;
Expand Down Expand Up @@ -499,6 +500,14 @@ public function tryChangeRoleWithMessages(string $roleFromBody, Participant $par

return false;
}

if ($participant instanceof PatrolParticipant) {
$participant->patrolLeader = null;
}

if ($participant instanceof TroopParticipant) {
$participant->troopLeader = null;
}

$participant->role = $role;
$this->participantRepository->persist($participant);
Expand Down

0 comments on commit 45bbc58

Please sign in to comment.