- Issue created by @fathershawn
- π«π·France DrDam
Did you check if this patch have been applied ?
"drupal/core": { "Refactor ImageStyleDownloadController": "https://git.drupalcode.org/project/drupal/-/merge_requests/10766.patch" }
This patch change things in core ImageStyleDownloadController in order to extract some technical elements, used in the ContextualImageStyleDownloadController::process method
- πΊπΈUnited States fathershawn New York
I didn't check if that patch had applied, but I did search my entire codebase for the existence of those methods and I did manually inspect the parent class. So I think we can be confident that it did not apply.
Further, patching core in a contrib module is not generally a good plan. A better approach would be to include the altered
ImageStyleDownloadController
here in your module and then also alter theimage.style_public
andimage.style_private
routes here in your module to use your substitute controller. - π«π·France DrDam
That's not the goal ... I don't want alter it, I want be able to extends (herite from it) without duplicate 40% of it's code...
see #2685905 β¨ Refactor ImageStyleDownloadController so derivatives can be generated by contrib modules Needs work for more informations
- πΊπΈUnited States fathershawn New York
Thanks - I did read that issue. The contextual crop approach is super useful - really like this idea!
I understand that swapping a modified class is more work but there are good reasons to do it:
- Users don't have to understand how to alter their composer.json if they aren't using patches already.
- I am using patches so I'm not sure why it didn't patch, but explicitly decorating a service or altering a route is more reliable.
- If a user uninstalls your module, the modifications are removed. With the patch approach when I uninstall the the module via Drupal the patch remains. Even if Icomposer remove
, the patch remains unless I'm already patching that module or core myself for another issue. - π«π·France DrDam
- I am using patches so I'm not sure why it didn't patch, but explicitly decorating a service or altering a route is more reliable.
I don't want altering any route, native controller work fine, and I need it continue making is job has he do. I juste want limit code duplication.
If you prefer not using this patch, the last release without it is the 2.1.4
- πΊπΈUnited States fathershawn New York
Thanks for considering my feedback.