src/Security/Voter/GroupAdminVoter.php
/**
     * If the `supports` method returns true, this function is called to know if the access to the ressource is given or not.
     *
     * @param string $attribute
     * @param Group  $subject
     */
If the `supports` method returns true, this function is called to know if the access to the ressource is given or not.
@param string $attribute
@param Group  $subject
If the ` supports ` method returns true this function is called to know if the access to the ressource is given or not . @param string $attribute @param Group $subject
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
    {
        $userLogged = $this->security->getUser();
        $isAdmin = $this->security->isGranted('ROLE_ADMIN');
        $isAdminOfGroup = $subject->getAdmins()->contains($userLogged);
        return $isAdmin || $isAdminOfGroup;
    }
protected function voteOnAttribute ( $ attribute , $ subject , TokenInterface $ token ) : bool { $ userLogged = $ this -> security -> getUser ( ) ; $ isAdmin = $ this -> security -> isGranted ( 'ROLE_ADMIN' ) ; $ isAdminOfGroup = $ subject -> getAdmins ( ) -> contains ( $ userLogged ) ; return $ isAdmin || $ isAdminOfGroup ; }
If the `supports` method returns true, this function is called to know if the access to the ressource is given or not.
If the ` supports ` method returns true this function is called to know if the access to the ressource is given or not .
/** @var User $userLogged */ //  Admin users can do anything