L
L
LobsterJoe2018-12-07 21:09:03
symfony
LobsterJoe, 2018-12-07 21:09:03

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;

or like this:
* @UniqueEntity(fields="username", message="Username already taken")
 */
class User implements UserInterface, LocationAwareInterface, \Serializable
{
    use LocationAwareTrait;

What are your opinions gentlemen?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Wells, 2018-12-14
@Alex_Wells

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 question

Ask a Question

731 491 924 answers to any question