All of these answers are excellent and show how to deal with this problem through structure. Although, when I had this problem, I realized that there should be a flaw in my plan and architecture, if I absolutely must have services that cause each other and cause conflicts. Instead of finding a job, I took a somewhat less complex and lasting approach - I restructured. I have moved violation methods from a service class to another service class. It took some rethinking, rethinking and copying / pasting skills, but I think the application is better for him.
I am not saying this is better than the other answers. I say this time, when this refactoring project was a better, faster and less complicated solution. I highly recommend it.
UPDATE Our final strategy is to reorganize all the utility functions of the "utility" into the baseService class, and then all other services that need auxiliary services extend the baseService. The new policy is to not inject injection services into other services unless there is a situation that prevents us from following this pattern of inheritance. This will give us a cleaner code base and less spaghetti footprint of injections. In addition, this eliminates the occurrence of this error.
source share