Are there cases where this is useful? If so, how do we restrict people from accessing methods of a class if it is called by a trigger? I need a use case scenario.
Hi @Roman Regmi
When a Community User Runs some functionality in Community Site they in background runs some logic and that logic runs from classes so these classes run with context of the community user which are external users, and they do not have access to run these classes in such cases we need to add the apex class in permission set or in the profile of these users(Community Users)
Classes runs even when they are adding in Permission Set or in Profiles because Usually a User with System admin Profile runs these classes and they have access to it.
Not sure if we can restrict a method of a class but yes we can restrict access to class
refer these
https://help.salesforce.com/s/articleView?id=sf.code_package_security.htm&type=5
https://salesforce.stackexchange.com/questions/72887/how-to-prevent-users-from-viewing-apex-code