Hi Marco, Thanks, but I don't want to maintain such methods which will likely have to be the mappers that I have now and was hopping to get away.
If Doctrine would have a "detach" that would generate a version of the raw entity as a plain PHP object, I could serialize that without having to create one pair of those loadFrom(To)SerializeableXXXDTO for each of my entities... - Mario On Fri, May 8, 2015 at 4:09 AM, Marco Pivetta <[email protected]> wrote: > Hey Mario, > > On 5 May 2015 at 00:04, mbneto <[email protected]> wrote: > >> Ok. Let's try this. >> >> My app handles products which are made of scalar values (like price, >> name) and of details, themselves made of other scalar values (size, weight >> etc) in a one->many relationship >> >> So >> >> Step 1 : action showProduct >> $product = $documentManager->find('Product', $id); >> $this->view->product = $product; >> $_SESSION['product'] = $product; // This is saving the product so I >> don't have to fetch it again and to guarantee that I will use the same no >> matter if the db changes from now until the end of the process >> > > Is this action needed? Why can't you store a "session-safe" version of the > object? ($product->toSerializableProductDTO(), kind-of) > > >> >> // Displays a form and the product information. The user decides if he >> wants to use this product. If he decides to do so calls Step 2 >> >> Step 2 : action confirm >> $this->view->product = $_SESSION['product']; >> $context->save(session_id, $product); // This context serializes the >> product object for future use and saves in a persistence medium (db, file, >> redis, memcache). in real life this context would save other objects needed >> as well >> > > If you redesign the product form around the DTO, this will also work. > > >> >> // Display a confirmation page with the details >> >> Step 3: action postback // At some point we will get called with the >> session_id saved on step 2. >> $id = $_GET['id']; >> $product = $context->restore($id); >> > > Here, something like > $productRepository->loadFromSerializableProductDTO($context->restore($id));. > This sort of operation merges data (manually) into the entity. > > >> $myClass->process($product); >> > > Keep on rocking! > > > > > Marco Pivetta > > http://twitter.com/Ocramius > > http://ocramius.github.com/ > > -- > 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.
