OK, one may argue that there shouldn't be business logic in entity. But sometimes there is a good reason. For example when getting roles for a user, one may force a role to be returned by default from within getter method, for example as explained here.
Anyway, my question is in many documentation pages it is either done in the function which creates/updates user or with doctrine listener. For example as mentioned here.
Doing it manually every time is extra work, meanwhile using doctrine listener seems inefficient for something which will be used rarely.
So, I was wondering, why not encode the password within setPlainPassword() function in entity? always one needs to encode the password after calling this method anyway.
Next part of the question is how to access the encoder from inside the User entity?
Thanks!