final public function hasRequiredRole(UserInterface $user = null, array $roles = [])
    {
        if ($user != null) {
            // Check if user's roles matches required roles
            $userRoles = $user->getRoles();

            foreach ($userRoles as $role) {
                if (\in_array($role, $roles)) {
                    return true;
                }
            }
        }

        return false;
    }
final public function hasRequiredRole(UserInterface $user = null, array $roles = [])
    {
        if ($user != null) {
            // Check if user's roles matches required roles
            $userRoles = $user->getRoles();

            foreach ($userRoles as $role) {
                if (\in_array($role, $roles)) {
                    return true;
                }
            }
        }

        return false;
    }
final public function hasRequiredRole ( UserInterface $ user = null , array $ roles = [ ] ) { if ( $ user != null ) { // Check if user's roles matches required roles $ userRoles = $ user -> getRoles ( ) ; foreach ( $ userRoles as $ role ) { if ( \ in_array ( $ role , $ roles ) ) { return true ; } } } return false ; }
Check if a user has at least one of the required roles

@param  UserInterface $user  the user
@param  array         $roles the roles
@return boolean       true if the user has the required role, false otherwise
Check if a user has at least one of the required roles