I want to create some virtual properties for an entity in an n:m
relation.
I have an User
, an Achievment
and an AchievementUser
entity. The value an user have in an Achievement is stored in the field value
in the entity AchievementUser
.
User -------- 1:n -------- AchievementUser -------- n:1 -------- Achievement
name:String value:Integer name:String
[...] [...]
Now I want to return the value
an user have in an achievement with the achievement itself. So I need a virtual property and a method getValue()
in the Achievement
entity, but to get the corresponding AchievementUser
object, I need the ID of the current logged in user.
How can I get this? Or is there an other possiblility to get the user value for an achievement? Thanks for your help!
Edit: I only have an API based application. Only the serializer executes the Getter method. Here is the content of my serializer file:
virtual_properties:
getValue:
serialized_name: value
type: integer
groups: ['achievement_default']