getUser(); $targetUser = $subject; if (!$currentUser instanceof User || !$targetUser instanceof User) { return false; } // editing your own roles or super admin flag is not allowed if ($currentUser === $targetUser) { return false; } // if the current user is impersonating, do not grant access if ($this->security->isGranted('IS_IMPERSONATOR')) { return false; } return $currentUser->isSuperAdmin(); } }