src/Http/Admin/Security/AdminVoter.php line 10
<?phpnamespace App\Http\Admin\Security;use App\Domain\Auth\Entity\Group;use App\Domain\Auth\Entity\User;use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;use Symfony\Component\Security\Core\Authorization\Voter\Voter;class AdminVoter extends Voter{protected function supports(string $attribute, $subject): bool{if($attribute == '') return false;if(str_contains($attribute, 'ROLE_')) return false;return true;}protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool{$user = $token->getUser();if (!$user instanceof User) {return false;}if($user->hasRole('ROLE_ADMIN')){if($user->getGroup()->getId() == Group::ADMIN_ID && $subject != 'only') return true;$rights = $user->getGroup()->getModulesRightSlug();foreach ($rights as $r) {if ($attribute == $r) return true;}}return false;}}