Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea of using more property info for serializer #123

Open
Hanmac opened this issue Feb 14, 2023 · 3 comments
Open

Idea of using more property info for serializer #123

Hanmac opened this issue Feb 14, 2023 · 3 comments

Comments

@Hanmac
Copy link

Hanmac commented Feb 14, 2023

I don't know if this is an idea for this project or if it should be done for a different one

my idea is to use the property info for the serialized class:

/**
 * ORM Column("json_serial")
 */
property ?Block $content;

if the DoctrineType could access the info of the property somehow, then it could know into which classes it is doing to denormalize.
Also it could get the serialize and deserialize context from the property and it wouldn't need extra stuff inside the json

while talking more with others, it seems it isn't as easy as i thought because the moment when doctrine is using the Type to get the data from the database, i can't access the property it is going into

so my idea probably need a different approach, so i need to get in between doctrine loading data from the database and it putting the data in the entities

@bpolaszek
Copy link
Contributor

Hi @Hanmac,

Unfortunately Doctrine Types have no knowledge of the property context: types are just asked to convert a PHP value to a database one and backwards.

There's been some work done about being able to have a little less verbose JSONs, it's still in progress here.

@Hanmac
Copy link
Author

Hanmac commented Feb 15, 2023

Yeah that's what I got from reading the code too

Sadly not even the column options would help there because I thought I could inject the Outer Type into the options of the column, but that part isn't used either for this.

So for my idea I probably need to go deeper into the hydrator to see if I can get the data before it is loaded into the entity

@Hanmac
Copy link
Author

Hanmac commented Feb 15, 2023

my newest idea is to inject myself into hydrateColumnInfo and mess with the 'type' property in the _cache

then i could use a Decorated Doctrine Type object that wraps around the real Doctrine Type while still having the info of the column

but that's very hacky

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

No branches or pull requests

2 participants