implement user moderation tools

This commit is contained in:
ghost 2023-10-09 19:31:25 +03:00
parent 42cef39589
commit 8d258c677b
5 changed files with 365 additions and 26 deletions

View file

@ -162,4 +162,49 @@ class UserService
$this->entityManagerInterface->flush();
}
}
public function toggleUserModerator(
int $userId
): void
{
if ($user = $this->getUser($userId))
{
$user->setModerator(
!$user->isModerator()
);
$this->entityManagerInterface->persist($user);
$this->entityManagerInterface->flush();
}
}
public function toggleUserStatus(
int $userId
): void
{
if ($user = $this->getUser($userId))
{
$user->setStatus(
!$user->isStatus()
);
$this->entityManagerInterface->persist($user);
$this->entityManagerInterface->flush();
}
}
public function toggleUserApproved(
int $userId
): void
{
if ($user = $this->getUser($userId))
{
$user->setApproved(
!$user->isApproved()
);
$this->entityManagerInterface->persist($user);
$this->entityManagerInterface->flush();
}
}
}