-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
About chained data persisters #540
Comments
Just tag your data persister services with The |
I am using autowiring, so I didn't need to tag it. My problem is that I have my own data persister for a doctrine entity, so both are running (doctrine data persister and mine).
|
Oops... Sorry, you're right. The documentation does not match the code. |
Actually... the code looks wrong to me. We should stop at the first persister supporting the class. It allows specializing. If a user wants to save the resource in several persistence layers, it needs to create a custom persister delegating to the inner ones. I would change this behavior as a bug fix. ping @gorghoa |
So, we shall disregard this comment api-platform/core#1967 (comment)? (ping @Taluu) Hence (re)introducing BC break? If this is really a thing to fix, the only thing to do is revert this PR api-platform/core#2064 and everything should be fine. |
Depending on how you look at it: It's a bug, so not a BC break. |
Still technically a BC break in my opinion, and at the heart of the solution. Maybe an acceptable one: not for me to say (nor will I be personally impacted. ie. I don’t mind what final decision is made). 🤷♀️ All I’m saying is that there is probably people who are relying on this “bug”. |
We don't cover BC breaks if you're relying on buggy behaviour. |
I'm all for reverting api-platform/core#2064. |
That is still a BC Break. In 2.2, all persisters were called. That wouldn't be the case in 2.3. I remind that this was done only because we wanted to return a different data when persisting. So this was not a "buggy behavior" as you call it ; adding the possibility to return the data (something new, the same one... doesn't matter) introduced the bc break, which was the point of my comment. So returning only the first supported persisted data is a BC Break. Disclaimer : I don't have any custom data persisters, but still. |
@Taluu It's a bug that's been around since 2.2. The original behaviour was already buggy. |
But yeah, I think it's a hard one. Because the documentation was only added later... |
Then IMO the name of the persister for what you describe as "faulty" is not correct. A chain is what it is : a chain that passes the processed data over the next link that supports it, until none are left. It's what @dunglas proposed #540 (comment). The name is kinda confusing then. |
@Taluu Well, it's not unprecedented: https://symfony.com/doc/master/cmf/components/routing/chain.html |
Chain is confusing, in Symfony, most (but not all) "chains" stop after the first match. In term of UX, changing the behavior will be more flexible for the end user. My proposal:
|
Done in api-platform/core#2175 |
Hi for all! |
Hi! Actually, I have the same question as @ghettovoice. In my simple case, I wanted to take full control of the deletion process of my User entity. I have User entity which has many relation to Address entity. I wanted to remove all the Address entities, but keep the User one, untouched. (Well, only some properties a bit cleaned up). Because this @dunglas Is there any chance that the Thank you. |
I guess it could to be consistent, WDYT @api-platform/core-team ? |
In my Symfony 4.1 app, I ended up overwriting the default Chain Data Persister in my services.yml as follows |
to me, it's a bug. |
done will be tagged in next release. |
Thanks @soyuka 👍 |
How to change the order the DataPersister execution ? Say I have 2 Persister that return true for support function in the Persister. Let's call it P1 and P2. Now How to control the order of the DataPersister execution ? I want to executed P2 and then P1. I am currently using ResumableDataPersisterInterface so the chain will not break. |
- explain how to avoid "vertical" DataPersisters chaining (api-platform#1313) - explicit how to use tag priority (api-platform#540)
In the documentation I can read this about DataPersisters:
However in ChainDataPersister class, persist and remove method executes all persisters than supports the entity:
This could be a bug or the documentation is wrong?
The text was updated successfully, but these errors were encountered: