-
-
Notifications
You must be signed in to change notification settings - Fork 223
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
FEATURE: Extensible followup after asset replacement #4816
base: 9.0
Are you sure you want to change the base?
FEATURE: Extensible followup after asset replacement #4816
Conversation
Allows implementing custom handlers to be called after an asset resource was replaced. This allows decoupling redirects for the replaced asset from the media package. Fixes: neos#4815
Note this will need another PR to the redirect package to (re)implement adding the redirect there. |
Thanks for the new interfaces, that makes the code much better! I have two concerns about the change to the asset replacement:
|
Yep good points both, the resources do still exist until we persist, so creating the URIs and redirects works fine (I have the actual handler ready here, just not made a PR yet). The repsonsibility issues is indeed one. I first thought we should make it configurable per resource target and whatnot, but it felt super overengineered for the one usecase we have for it right now. I suppose you will rarely (ever?) use multiple (cloud) storages at once, so IMHO any cloud storage implementation could just overwrite the interface via settings and refer back to the default redirect one if the resource target is not the cloud target. BUT we could introduce a configuration and figure out the right one to call (or even a chain?) instead of just grabbing the interface from the objectManager. I am open to both, just wanted to get this part of the code out there for now :) |
Moves handling of asset redirects after resource replacement to the redirect package. See: neos/neos-development-collection#4815 neos/neos-development-collection#4816
Thanks for clarifing. I think ONE service is fine without a chain. But I assume we need some configuration to decide, which one is to use. OR we remove the asset redirect from the RedirectHandler package and provide a separate package, but this would make the integration for most use cases more complex. |
As said, I think any specific service like we would deliver for our google cloud package could check if the redirect handler is installed and use that handler as fallback if the resource is not actually stored in google cloud. Would break down if you had S3 + google cloud + redirect handler installed, at that point one of the cloud ones would be left out, but I think that's fine? But yeah if we want this I woudl say we have a configuration with a default handler and a map of resource target class name to handler as an override of the default one.
|
Ahh, you already thining about configuration per asset source. I thought we are talking about the current object manager approach. |
Just choosing one implementation can be done via Object.yaml by overwriting the class for the interface. That would already work. |
But AFAIK this could lead to flaky behavior, as we can't specifiy a loading order of the packages |
requirement order is loading order, BUT you can always choose for your project in a global Objects.yaml with how the code is right now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for cleaning this up and introducing the fitting interfaces ❤️
use Neos\Media\Domain\Model\AssetInterface; | ||
|
||
/** | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems there is a little place of a doc comment already anticipated and i would very much like this.
Co-authored-by: Marc Henry Schultz <85400359+mhsdesign@users.noreply.github.com>
Regarding:
This could even be chance to be less cofusing. Currently redirects for assets only work if you adjust the default rewrite rules, to actually pass requests for resources to PHP. If that feature was moved to a separate package, maybe more people would actually read the documentation. 😇 |
Allows implementing custom handlers to be called after an asset resource was replaced. This allows decoupling redirects for the replaced asset from the media package.
Also handles some unchecked couplings to asset methods via new interfaces and cleans up a bit of code.
Fixes: #4815