I think you mix up some terminology: An object is an entity by nature if it is characterized and identified by its identity. In other words: if it has a primary key in the database it probably an entity and can be modelled into a Doctrine Entity.
Value object ar characterized not by identity, but by value. A date or datetime is characterized by value, not by identity and those cannot be used as entities. Regards Maarten van Leeuwen > Op 8 sep. 2017 om 17:11 heeft Dennis Matveyev <[email protected]> het > volgende geschreven: > > In my code I currently have an active record implementation of a Staff > object. Namely, that object self-populates at creation time, and > self-reloads when required. > > class Staff > { > private $id; > private $name; > private $email; > > //all the getters and setters > } > > I changed the code where I pulled out database code out of it to where it now > populates from the outside. One of the next steps I can take is make this > object into a Doctrine Entity, which is a fairly-well understood concept to > me (I have existing entities in my code) > Before going that route, I thought .. what if I make it into an immutable > value object. Will it benefit me? > > And that is my question here. Staff is used as part of a session and > typically does not need to be mutable. > As part of making it a value object I can remove all the setters and move all > initialization and object-loading code into the constructor. > > This is where I'm struggling ... If I do this > can I still use the object with Doctrine? > Is doing this a good idea? > > > -- > You received this message because you are subscribed to the Google Groups > "doctrine-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/doctrine-user. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
