/
AleksWork
/
diary_plants
Обзор
Документация
Войти
/
AleksWork
/
diary_plants
Код
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/Controller/Web/Dashboard/User/DeleteUser/Manager.php
36 строк
1 KB
AlexeySerov
Add vote to user managers
14 май 2026, 16:57
14 май 2026, 16:57
fa52ab1
Код
Авторство
О чём код?
<?php namespace App\Controller\Web\Dashboard\User\DeleteUser; use App\Domain\Service\UserService; use Symfony\Component\HttpFoundation\Request; use App\Domain\Exception\AccessDeniedException; use Symfony\Contracts\Translation\TranslatorInterface; use App\Application\Security\Voter\GroupOwnershipVoter; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; final class Manager { public function __construct( private readonly UserService $userService, private readonly TranslatorInterface $translator, private readonly AuthorizationCheckerInterface $authChecker ) { } public function deleteData(int $id, Request $request): array { $user = $this->userService->find($id); if (!$this->authChecker->isGranted(GroupOwnershipVoter::DELETE, $user)) { $message = $this->translator->trans('security.access_denied.delete'); throw new AccessDeniedException($message); } $this->userService->deleteWithFile($id); $message = $this->translator->trans('user.flash.deleted', [], 'messages'); $request->getSession()->getFlashBag()->add('success', $message); return ['success' => true]; } }