Florent is correct about Evans: he gives an example of a route value object containing 2 cities ans a highway as entities (in my edition on page 98-99).
As a (quick and dirty) practical solution maybe you could just give that Route (or your ValueObject containing a $obj1 and $obj2) an id, thus making it an entity... Probably better solution: make a value object yourself, not using embeddables. See for instance https://groups.google.com/forum/#!topic/dddinphp/IQOYEG1zL30 (first posting) and http://verraes.net/2013/02/casting-value-objects/ On Sunday, 16 March 2014 01:50:00 UTC+1, Florent Paterno wrote: > > Thx Marco for your answer. > > But according to Eric Evans book about DDD, VO can contains reference > entities. > > So it's not possible with Doctrine 2 to have VO Collections in entity ? > > Le vendredi 14 mars 2014 18:00:28 UTC+1, Marco Pivetta a écrit : >> >> Hi Florent, >> >> A ValueObject cannot reference entities, it can only contain values. >> >> Cheers, >> >> Marco Pivetta >> >> http://twitter.com/Ocramius >> >> http://ocramius.github.com/ >> >> >> On 14 March 2014 17:22, Florent Paterno <[email protected]> wrote: >> >>> Hi guys, >>> >>> I'm trying to use Doctrine embedded collection (with Doctrine 2.5.0-DEV) >>> and have some problem with it. >>> >>> I've 2 classes : >>> >>> 1 classic entity with value objects collection >>> >>> class Entity{ >>> protected $id; // integer >>> protected $valueObjects; // Doctrine ValueObject ArrayCollection >>> } >>> >>> and a value object class with several properties (object). >>> >>> class ValueObject{ >>> protected $obj1; // Obj1 >>> protected $obj2; // Obj2 >>> } >>> >>> Here is my ValueObject definition (yml) : >>> >>> ValueObject: >>> type: embeddable >>> fields: >>> obj2: >>> type: object >>> manyToOne: >>> obj1: >>> targetEntity: Obj1 >>> >>> But nothing happens ... How can i define value object collection ? >>> >>> -- >>> 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 http://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 http://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
