/
githubmirror
/
symfony
Обзор
Документация
Войти
/
githubmirror
/
symfony
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
8.2
src/Symfony/Component/Security/Http/Attribute/IsGrantedContext.php
48 строк
2 KB
Nicolas Grekas
Remove non-final readonly classes
04 апр 2025, 15:32
04 апр 2025, 15:32
bbba700
Код
Авторство
О чём код?
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Http\Attribute; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\AccessDecision; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter; use Symfony\Component\Security\Core\User\UserInterface; class IsGrantedContext implements AuthorizationCheckerInterface { public function __construct( public readonly TokenInterface $token, public readonly ?UserInterface $user, private readonly AuthorizationCheckerInterface $authorizationChecker, ) { } public function isGranted(mixed $attribute, mixed $subject = null, ?AccessDecision $accessDecision = null): bool { return $this->authorizationChecker->isGranted($attribute, $subject, $accessDecision); } public function isAuthenticated(): bool { return $this->authorizationChecker->isGranted(AuthenticatedVoter::IS_AUTHENTICATED); } public function isAuthenticatedFully(): bool { return $this->authorizationChecker->isGranted(AuthenticatedVoter::IS_AUTHENTICATED_FULLY); } public function isImpersonator(): bool { return $this->authorizationChecker->isGranted(AuthenticatedVoter::IS_IMPERSONATOR); } }