Doctrine User Entity in Symfony: knowing the location of the avatar

Let's say I have a Doctrine User Entity. Every user has an avatar and there's of course a specific folder on the webserver where these avatars reside. My question is: should the User Entity know this location?

I'm currently storing the avatar folder URL as a parameter in Symfony2. I'm injecting this parameter into Twig so that Twig can print the correct URL. I considered also injecting the parameter into the User Entity, e.g. for when a user is removed and I'd like to let the Entity remove the avatar image. However different sources mention that Doctrine Entity's are mere POPO's (Plain Old PHP Object) and that it's bad practice to inject anything into them.

This suggests that the answer to my question is 'No'. Which raises a new question: where should the User deletion business logic reside? And how does this know the location of the avatar?


I think you could use a UserManager service where all this business logic would be located.

The shorter solution is to set the path in the User entity and do your logic there as you don't need any external service to save/delete the user avatar file, as seen here :

Need Your Help

Python: Open() using a variable

python string-formatting

I've run into a problem when opening a file with a randomly generated name in Python 2.6.

How to get the details of the user using restfb.?

java facebook json javabeans restfb

I am trying to get the lastname of my profile using restfb.But but each time the username is returned as null.I already have the acess token and permissions.I guess t some problem with the JSon obj...