[Feature] Prevent sending notification to user when bulk reassign

This commit is contained in:
2022-10-06 21:44:23 +02:00
parent 86cfd87d71
commit cf0252b469
5 changed files with 11 additions and 9 deletions

View File

@@ -62,6 +62,7 @@ class UserRefEventSubscriber implements EventSubscriberInterface
&& $period->getUser() !== $this->security->getUser()
&& null !== $period->getUser()
&& $period->getStep() !== AccompanyingPeriod::STEP_DRAFT
&& !$period->isPreventUserIsChangedNotification()
) {
$this->generateNotificationToUser($period);
}

View File

@@ -127,7 +127,7 @@ class ReassignAccompanyingPeriodController extends AbstractController
$period = $this->courseRepository->find($periodId);
if ($period->getUser() === $userFrom) {
$period->setUser($userTo);
$period->setUser($userTo, true);
}
}

View File

@@ -265,6 +265,8 @@ class AccompanyingPeriod implements
*/
private ?Comment $pinnedComment = null;
private bool $preventUserIsChangedNotification = false;
/**
* @ORM\Column(type="text")
* @Groups({"read", "write"})
@@ -1048,6 +1050,11 @@ class AccompanyingPeriod implements
return false;
}
public function isPreventUserIsChangedNotification(): bool
{
return $this->preventUserIsChangedNotification;
}
public function isRequestorAnonymous(): bool
{
return $this->requestorAnonymous;
@@ -1343,11 +1350,12 @@ class AccompanyingPeriod implements
return $this;
}
public function setUser(?User $user): self
public function setUser(?User $user, bool $preventNotification = false): self
{
if ($this->user !== $user) {
$this->userPrevious = $this->user;
$this->userIsChanged = true;
$this->preventUserIsChangedNotification = $preventNotification;
foreach ($this->userHistories as $history) {
if (null === $history->getEndDate()) {