I have an entity Book
. Title of this Book
is stored in different languages (the entity Book
is associated with BookTranslates
as OneToMane
).
The entity Book
is used as a form field in several places (like select). For this, I need to set __toString ()
for the Book
entity, which will return the title of the Book
in the user's language.
I tried to get the user inside the entity by passing TokenStorageInterface
in the __construct ()
method of the Book
class, but the doctrine never calls the __construct ()
method in that case.
Brief statement of the problem:
__toString ()
in entity must return a field of one of the related entities. Which specifically related entities - depends on the current user. How to implement it correctly?