rompetomp / inertia-bundle

Inertia.js server-side adapter for Symfony
MIT License
153 stars 41 forks source link

Default serializer, output nested entity #23

Closed andrelec1 closed 3 years ago

andrelec1 commented 4 years ago

I have a entity that contains another entity... I load the entity througth doctrine and passe it to the inertia render.

$transaction = $this->getDoctrine()->getRepository(Transaction::class)->find($id);
return $inertia->render('transaction/show', [
            'entity' => $transaction
        ]);

But when i inspect the entity with the vue-devtool a found some properties in it ( seem from doctrine ? ) ! image

So... I think we are all ok with the fact we didn't want __cloner__, __initializer__ and __isInitialized__ ...

But, its my jobs to sananitize my object before sending it to inertia ( and the sf serializer ) ? I have to use a real serializer at this point ? Ok we can concidere this like a bug in this vendor and we need to finding a walkaround (PR) ?

aleksblendwerk commented 4 years ago

In my opinion this is beyond the scope of this bundle and it shouldn't mess with the stuff you pass as props at all. Otherwise you'll just end up with situations like in #21 again.

I hear you when saying that transforming objects into the final form you want for your response is a bit cumbersome and inconvenient in Symfony currently but there has to be another solution for that. It will just end up in trouble if this bundle does any conversion magic, I think.

rompetomp commented 3 years ago

I agree with @aleksblendwerk here. This is out of scope of this package.

Kind regards

andrelec1 commented 3 years ago

Yeah this why i ask before sending a PR ... I didn't say is combersome, i say i don't kwon if its time for me to do it or not ...

At this point fee is just a simple nested object in my Transaction object ... Getting the object with Doctrine is very common ... So this is realy basic usage... and this why i aks ...