I cant find any satisfactory solution for the problems which I sometimes meet. For example we have Article, Photo and Comment entities, I want to make Article and Photo commentable. So, there are same approaches:
1. For all entities like Article, Photo make specific enitity like CommentPhoto, CommentArticle. But it makes me crazy when I duplicate the same code...
2. Use mappedSuperClass. But it forces me to extends class like Article - the problem occurs, when i want make Articles for example 'likeable' and I cant do that because i can extend only one class. There are traits which would be helpful but they are available since php5.4.0.
3. So i want to use interface "Commentable" and implement it entities. Then i want to Create entity with relation to this interface. I know there is something like "resolve target entities" (http://symfony.com/doc/master/cookbook/doctrine/resolve_target_entity.html) it allows to configure relationship with interface but this configuration is static (Correct me if I am wrong -> maybe I could configure in config.yml more than one entity for the same interface ?? )
So my question is: Is there any other approach? Or how to use "resolve target entities" to achieve this?
Edit: 4. fourth approach is to add fields 'entity_type', 'entity_id' to Comment, but it is still not clear as I dreamt...