/
AleksWork
/
diary_plants
Обзор
Документация
Войти
/
AleksWork
/
diary_plants
Код
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/Controller/Web/Dashboard/UserMessage/DeleteUserMessage/Manager.php
35 строк
1 KB
AlexeySerov
Add get user message controller and manager
01 июн 2026, 16:57
01 июн 2026, 16:57
c1450b4
Код
Авторство
О чём код?
<?php namespace App\Controller\Web\Dashboard\UserMessage\DeleteUserMessage; use App\Domain\Service\UserMessageService; 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 UserMessageService $userMessageService, private readonly TranslatorInterface $translator, private readonly AuthorizationCheckerInterface $authChecker ) { } public function deleteData(int $id, Request $request): array { $userMessage = $this->userMessageService->find($id); if (!$this->authChecker->isGranted(GroupOwnershipVoter::DELETE, $userMessage)) { $message = $this->translator->trans('security.access_denied.delete'); throw new AccessDeniedException($message); } $this->userMessageService->removeById($id); $message = $this->translator->trans('user-message.flash.deleted', [], 'messages'); $request->getSession()->getFlashBag()->add('success', $message); return ['success' => true]; } }