mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-03 05:23:49 +00:00
DX: apply rector rules up to php8.0
This commit is contained in:
@@ -53,35 +53,22 @@ final class NotificationVoter extends Voter
|
||||
}
|
||||
|
||||
if ($subject instanceof Notification) {
|
||||
switch ($attribute) {
|
||||
case self::COMMENT_ADD:
|
||||
return false === $subject->isSystem() && (
|
||||
$subject->getAddressees()->contains($user) || $subject->getSender() === $user
|
||||
);
|
||||
|
||||
case self::NOTIFICATION_SEE:
|
||||
case self::NOTIFICATION_TOGGLE_READ_STATUS:
|
||||
return $subject->getSender() === $user || $subject->getAddressees()->contains($user);
|
||||
|
||||
case self::NOTIFICATION_UPDATE:
|
||||
return $subject->getSender() === $user && false === $subject->isSystem();
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException("this subject {$attribute} is not implemented");
|
||||
}
|
||||
return match ($attribute) {
|
||||
self::COMMENT_ADD => false === $subject->isSystem() && (
|
||||
$subject->getAddressees()->contains($user) || $subject->getSender() === $user
|
||||
),
|
||||
self::NOTIFICATION_SEE, self::NOTIFICATION_TOGGLE_READ_STATUS => $subject->getSender() === $user || $subject->getAddressees()->contains($user),
|
||||
self::NOTIFICATION_UPDATE => $subject->getSender() === $user && false === $subject->isSystem(),
|
||||
default => throw new UnexpectedValueException("this subject {$attribute} is not implemented"),
|
||||
};
|
||||
} elseif ($subject instanceof NotificationComment) {
|
||||
switch ($attribute) {
|
||||
case self::COMMENT_ADD:
|
||||
return false === $subject->getNotification()->isSystem() && (
|
||||
$subject->getNotification()->getAddressees()->contains($user) || $subject->getNotification()->getSender() === $user
|
||||
);
|
||||
|
||||
case self::COMMENT_EDIT:
|
||||
return $subject->getCreatedBy() === $user && false === $subject->getNotification()->isSystem();
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException("this subject {$attribute} is not implemented");
|
||||
}
|
||||
return match ($attribute) {
|
||||
self::COMMENT_ADD => false === $subject->getNotification()->isSystem() && (
|
||||
$subject->getNotification()->getAddressees()->contains($user) || $subject->getNotification()->getSender() === $user
|
||||
),
|
||||
self::COMMENT_EDIT => $subject->getCreatedBy() === $user && false === $subject->getNotification()->isSystem(),
|
||||
default => throw new UnexpectedValueException("this subject {$attribute} is not implemented"),
|
||||
};
|
||||
}
|
||||
|
||||
throw new UnexpectedValueException();
|
||||
|
Reference in New Issue
Block a user