Answer the question
In order to leave comments, you need to log in
Location - Trait or Embeddable?
Greetings!
The situation is this - I have a set of entities that store some identical fields (latitude and longitude for example). Confused by the implementation details, I would like to find out which way would still be preferable - to create a location like this:
/**
* @ORM\Embedded(class="App\Entity\Embeddable\Location\Location")
* @Groups({"get"})
*/
protected $location;
* @UniqueEntity(fields="username", message="Username already taken")
*/
class User implements UserInterface, LocationAwareInterface, \Serializable
{
use LocationAwareTrait;
Answer the question
In order to leave comments, you need to log in
I would prefer the first option, as it will allow you to change the annotations if something happens. In addition, the second option forces you to use annotations, and the first gives you freedom of choice, allows you to use the parser that you use in the project (if you do not use annotations, for example).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question