[Flow] Access to related object in One-to-many relation
Matteo C.
mathaios76 at gmail.com
Thu Sep 12 14:44:25 CEST 2013
Thank you Gianluca, this is brilliant design ! In other frameworks
decoupling associations is often cumbersome. I'm liking Flow more and more!
Ciao
Matteo
> Hi Matteo,
> in your model "Address", you can add on property "contact", annotation
> "@lazy"
>
> /**
> * @lazy
> */
> protected $contact;
>
> In this way, entity "Contact" will be loaded only if you use it (in
> example in your fluid template). So, if in your template you access to
> property "contact" as "address.contact", this will be loaded.
> If you get a Address from repository and you don't retrieve property
> "contact", Contact with its addresses, it will be not loaded. So, you
> can retrieve only an Address object, without load its Contact.
>
> Regards,
> Gianluca
>
>
> Il 11/09/2013 00:13, Matteo C. ha scritto:
> > Dear Flow gurus,
> >
> > I've just started to explore this fantastic framework but I'm already
> > struggling with it, in particular this is my case, written as most
> > succinctly as possible:
> >
> > - Contact class with a one-to-many relation (bidirectional) to an Address
> > class
> > - Initially I did setup the relation as an aggregate, whit the Contact
> > class as the aggregate root. Like this I was able to add and delete
> > Addresses using the Address controller and the Contact repository.
> > - reading around I discovered that being an aggregate, it was not
> possible
> > to access an Address directly in order to be edited, but the whole
> > collection needed to be handled, I'm I correct ?
> > - so I created an Address Repository and injected in to the Address
> > controller, but once I pass from the view the identifier of the Address
> > object I wish to edit, I'm getting again the whole object structure, that
> > is the Contact object and the full Addresses collection.
> > What is the correct procedure to retrieve only an Address object and edit
> > it ?
> >
> > For the good souls that want to throw a look into it, I did create a gist
> > (bad coding ahead, it's just a test...)
> >
> > https://gist.github.com/Teox76/6516255
> >
> > Thank you for any tips !!
> >
>
> --
> Gianluca Strafella
>
> Software Developer
> gianluca.strafella at webformat.com
> Tel. +39-0427-926.389
>
> WEBFORMAT srl ? www.webformat.com
> Via S. Francesco d'Assisi, 6 ? 20122 MILANO
> Corte Europa, 12 - 33097 SPILIMBERGO (PN)
>
>
More information about the Flow
mailing list