Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Default serializer, output nested entity #23

Closed
andrelec1 opened this issue Nov 29, 2020 · 3 comments
Closed

Default serializer, output nested entity #23

andrelec1 opened this issue Nov 29, 2020 · 3 comments

Comments

@andrelec1
Copy link
Contributor

andrelec1 commented Nov 29, 2020

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
Copy link
Contributor

aleksblendwerk commented Nov 30, 2020

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
Copy link
Owner

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

Kind regards

@andrelec1
Copy link
Contributor Author

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 ...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants